diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt
index 5acc71f559..f8847a6458 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt
@@ -46,6 +46,15 @@ $(document).ready(function() {
+[% FOR m IN messages %]
+
+ [% SWITCH m.code %]
+ [% CASE 'invalid_mimetype' %]The file used does not have a valid format. Only csv and txt are allowed.
+ [% CASE %][% m.code %]
+ [% END %]
+
+[% END %]
+
- Export bibliographic records
diff --git a/tools/export.pl b/tools/export.pl
index d0dcd2cd8c..6736a4e4d6 100755
--- a/tools/export.pl
+++ b/tools/export.pl
@@ -86,6 +86,17 @@ if (
my %branchmap = map { $_ => 1 } @branch; # for quick lookups
+my @messages;
+if ( $op eq 'export' ) {
+ my $filename = $query->param('id_list_file');
+ my $mimetype = $query->uploadInfo($filename)->{'Content-Type'};
+ my @valid_mimetypes = qw( application/octet-stream text/csv text/plain );
+ unless ( grep { /^$mimetype$/ } @valid_mimetypes ) {
+ push @messages, { type => 'alert', code => 'invalid_mimetype' };
+ $op = '';
+ }
+}
+
if ( $op eq "export" ) {
my $export_remove_fields = $query->param("export_remove_fields") || q||;
@@ -317,6 +328,7 @@ else {
authority_types => $authority_types,
export_remove_fields => C4::Context->preference("ExportRemoveFields"),
csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
+ messages => \@messages,
);
output_html_with_http_headers $query, $cookie, $template->output;