Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong behavior after the first file read #29

Open
bamarni opened this issue Jan 29, 2013 · 6 comments
Open

Wrong behavior after the first file read #29

bamarni opened this issue Jan 29, 2013 · 6 comments

Comments

@bamarni
Copy link

bamarni commented Jan 29, 2013

Hi,

When I read from the input file the first time, everything is correct, but when the file is changed and I read again, the load event will be triggered 2 times, when I change the file again, it's getting triggered 3 times, and so on... This is obviously wrong, the real Filereader object doesn't behaves like this.

Here are some logs :

debugMode : ,true 
File Input add...,my_input_id,false,,, 
MouseOverEvent...,my_input_id 
FileInput Event click[object Object] 
Browsing...,my_input_id 
File Input change...,my_input_id 
FileInput Event change[object Object] 
FileReader read...,my_input_id,A.JPG,readAsDataURL 
FileReader Event loadstart[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event load[object Object]true 
FileReader result...,my_input_id.A.JPG 
FileReader Event loadend[object Object]true 
FileInput Event click[object Object] 
Browsing...,my_input_id 
File Input change...,my_input_id 
FileInput Event change[object Object] 
FileReader read...,my_input_id,B.jpg,readAsDataURL 
FileReader Event loadstart[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event progress[object Object]true 
FileReader Event load[object Object]true <====== WRONG FROM HERE
FileReader result...,my_input_id.A.JPG 
FileReader Event loadend[object Object]true <=== TO HERE
FileReader Event load[object Object]true 
FileReader result...,my_input_id.B.jpg 
FileReader Event loadend[object Object]true 

@Jahdrien if you don't have time to fix this please give me some pointers and I'd be happy to submit a PR, thanks

@bamarni
Copy link
Author

bamarni commented Feb 11, 2013

ping @Jahdrien

@itsmattking
Copy link

Occurs for me as well. Would love a fix.

@bamarni
Copy link
Author

bamarni commented Mar 7, 2013

@MattKing17 : here is the dirty hack I've done for now (bamarni@74546ba).

I didn't go further in my investigation since it fixed my issue, I'm not sure though wether the issue is in this library or on the underlying swfObject it uses.

@itsmattking
Copy link

thanks @bamarni! I'm trying to remove all dependencies on jquery from this plugin and ended up rewriting an implementation myself. I think what I'm going to do is refactor it to only support one file handler at a time. It seems that the reader result comes in multiple times, it ends up triggering load events for all file handlers ever registered. This works for my case since I only care about people uploading one file at a time.

@john-bai
Copy link

ping @Jahdrien again.

@encore1908
Copy link

ping @Jahdrien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants