ProgerXP / FileDrop

Self-contained cross-browser pure JavaScript class for Drag & Drop and AJAX (multi) file upload.
filedropjs.org
The Unlicense
264 stars 61 forks source link

File with size 0 #13

Open rafaelmaiolla opened 10 years ago

rafaelmaiolla commented 10 years ago

Is it possible to add a property to disable the check for file size > 0?

I want to show a error for the user when he selects a file with size 0. Because the actual behavior, of ignoring those files, may lead the user to think that it is not working and then try again.

ProgerXP commented 10 years ago

Not directly. I don't want to add more options than necessary. You can still override fileSetup event (it's fired for every File in the dataTransfer) and either track zero-sized files and show them later using other means or set passed file's size to something other than 0 - e.g. -1. This is a dirty trick but lets you intermix empty files into result. Still, I would intercept the event instead of this way.

One of the other reasons why I want to specifically skip empty files is because this is the only way to track dropped directories (and the method is named eventFiles). I doubt browser will ever give a FIle with size = 0 in case of error unless it's really empty.