bgrins / filereader.js

A lightweight wrapper for the JavaScript FileReader interface
http://bgrins.github.com/filereader.js/
MIT License
413 stars 86 forks source link

filereader.js fileID for multiple groups #7

Closed wdahab closed 13 years ago

wdahab commented 13 years ago

One more thing I noticed. Don't know if you actually still even use this code actively, or if anyone else might come along and want to use it as well.

Currently fileID it is ascending for all items, regardless of how it's grouped. e.g. group 0 file 0, group 0 file 1, group 1 file 2. This conflicts with FilereaderJS.output[groupID].files[fileID], since FilereaderJS.output[1].files[2] is looking at the 2nd index, instead of the 0th where the file is actually stored. Any reason for this setup? It seems to work regardless on your example page, but not in my deployment.

I simply modified filereader.js:100 from: fileID: getFileID(), to: fileID: i,

This makes it work for me, and I think is a bit more intuitively how the files should be stored.

bgrins commented 13 years ago

The biggest project I using this with is http://instantsprite.com.

Originally I meant for fileID to be a unique ID, just to keep track of how many files had been loaded on the page. As it turns out, I don't even use this functionality on instant sprite (I just keep all the images in an array, and read the length of it). I can definitely see why you would want the behavior you describe, and I don't really have a problem with keeping track of both.

I could change it to fileID: i and uniqueID: getUniqueID()

bgrins commented 13 years ago

Fixed here: https://github.com/bgrins/filereader.js/commit/be2c74250637ded09702098592b86712c402bfe7

Thanks for your feedback, the file uploading portion is new and relatively untested, so I appreciate you catching these issues. Let me know if you see anything else or have anything else you want to add in.