I've read quite a few answers on SO about this, and most advise using the acceptedFiles
property to specify the accepted mime types.
However, the DropZone docs say:
Mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all.
I'm trying to upload a .csv file, and (using material-ui-dropzone
), so far I've tried:
<Dropzone
acceptedFiles={['.csv', 'text/*']}
showPreviews={true}
showFileNamesInPreview={true}
/>
<Dropzone
acceptedFiles={'.csv', 'text/*'}
showPreviews={true}
showFileNamesInPreview={true}
/>
<Dropzone
acceptedFiles={'.csv', 'text/csv'}
showPreviews={true}
showFileNamesInPreview={true}
/>
...etc., but so far none are working:
.csv
files as grayed out.csv
file to DropZone gets a "File SeriesNotes.csv was rejected. File type not supported." messageWhat is the correct way to solve this for material-ui-dropzone
(or for any version of DropZone)?
On the Data tab, in the Get & Transform Data group, click From Text/CSV. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import. In the preview dialog box, you have several options: Select Load if you want to load the data directly to a new worksheet.
js is one of the most popular drag and drop JavaScript libraries. It is free, fully open source, and makes it easy for you to handle dropped files on your website. It's meant to look good by default, and is highly customizable. Documentation Download.
By providing accept prop you can make the dropzone accept specific file types and reject the others. The value must be an object with a common MIME type as keys and an array of file extensions as values (similar to showOpenFilePicker 's types accept option).
Whether your users use an outdated browser, or have JavaScript enabled, Dropzone got you covered. One main goal when creating Dropzone was to have file previews that are not only practical, but also look good. That's why the default design of Dropzone looks great without you needing to do anything. Need a server?
Because of HTML5 File API differences across different browsers during the drag, Dropzone might not be able to detect whether the files are accepted or rejected in Safari nor IE. Furthermore, at this moment it's not possible to read file names (and thus, file extensions) during the drag operation.
You can get all the source code on GitHub, as well as installation instructions. If you encounter an issue with this library, this is the place to create an issue. All the documentation about Dropzone, and the multiple ways to configure and customise it, can be found on GitBook. If you need help, there are GitHub Discussions and Stackoverflow.
After lots of trial and error, this worked for me.
acceptedFiles={[".csv, text/csv, application/vnd.ms-excel, application/csv, text/x-csv, application/x-csv, text/comma-separated-values, text/x-comma-separated-values"]}
The main one on windows was the .csv the rest are just in case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With