I'm using webkitdirectory to create an input that allows uploading an entire folder (rather than selecting individual files). I know it's non-standard and shouldn't be used in production.
I'm uploading a specific type of folder where there is one very large file that isn't needed, and many other small files. The upload takes a long time because there's a large file, but because coincidentally that's also the one file I don't actually need on the server side, I'm wondering if there's any way to filter it out prior to being uploaded?
webkitRelativePath is a read-only property that contains a string which specifies the file's path relative to the directory selected by the user in an <input> element with its webkitdirectory attribute set.
webkitdirectory is a property that reflects the webkitdirectory HTML attribute and indicates that the <input> element should let the user select directories instead of files. When a directory is selected, the directory and its entire hierarchy of contents are included in the set of selected items.
You can allow folder upload by adding these attributes empty "webkitdirectory directory" into your react-dropzone input. by using this user can't select a single file.
Should we assume that the large file has the same name pattern and/or content type as the files you want? Otherwise it should be possible to exclude it from the selection by using the accept
attribute.
Otherwise I see 2 alternative approaches:
Process the list of files on submit and construct a request containing only the ones you want to send, or
Scan the $(myInput).files
list in its change
listener and copy everything you actually want to submit to another <input name="filesField" type="file" multiple style="visibility: hidden">
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