How to distinguish folders and files from dragging and dropping Ajax upload to FireFox

I cannot find a way to distinguish between folders and files in FireFox Ajax. Looks like there are no signs in FireFox FileAPI that can determine if this is a folder or a file.

However, I see that Google docs can somehow distinguish between folders and files. It does not depend on extensions or file length, files without extensions are loaded correctly, and 0-tenth files are downloaded without problems.

How to distinguish files and folders from D&D in FF?

+1
firefox ajax drag-and-drop fileapi ajax-upload
Dec 04 '13 at 15:00
source share
1 answer

This blog post suggests trying to read the file and respond to the exception that will be thrown if it is a folder.

if (!f.type && f.size%4096 == 0 && f.size <= 102400) { try { reader = new FileReader(); reader.readAsBinaryString(f); } catch (NS_ERROR_FILE_ACCESS_DENIED) { //file is a directory } } 

In general: first suppose the folder is a file and treats it as one, at some point everything will go wrong, and you can respond to it.

+3
Dec 08 '13 at 0:18
source share



All Articles