I am trying to allow CSV files in a dashboard menu page like this..
<form method="post" enctype="multipart/form-data"> <input type="file" name="csv_file" id="csv_file" multiple="false" accept=".csv" /> <input type="submit" value="Upload" /> </form> require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); $attachment_id = media_handle_upload ( 'csv_file', 0, array(), array( 'test_form' => false, 'mimes' => array( 'csv' => 'text/csv', ), ) );
When I upload a CSV file to the form I get the following error message...
Sorry, this file type is not permitted for security reasons.
Can anyone spot what I am doing wrong? I had assumed I had allowed the CSV mime type in the above code.