question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

input type="file" weird behavior

See original GitHub issue

It seems that reused input elements with type “file” do not clear their selected file correctly see: http://jsfiddle.net/mnypy1do/3/

also if you explicitly do: <input type="file" value=""/> (http://jsfiddle.net/mnypy1do/4/) the same thing happens

I don’t know what the proper behavior here should be, probably the best would be to pass in the FileList back into the input via files prop when something gets selected

The only problem is that getting an empty FileList is not an obvious thing, can’t just do new FileList(), you have to

var input = document.createElement("input");
input.type = "file";
var emptyFiles = input.files;

see: http://jsfiddle.net/mnypy1do/5/

and passing null wont worke either, unless there would be special handling for this (input.files = null) does nothing

Any thoughts on this? Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
kruczycommented, Jun 10, 2016
0reactions
kruczycommented, Jun 21, 2016

Cool, thanks alot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Input type="file" showing weird behavior when used along ...
You are directly trying to mutate the state, productPicture=URL.createObjectURL(e.target.files[0]) which is wrong. Here you are not setting ...
Read more >
input type="file" weird behavior · Issue #187 · preactjs/preact
That being said, this behavior is definitely a bit odd. We normalize input values in a similar way, it just doesn't apply for...
Read more >
Strange behavior during file upload - CodeRanch
Strange behavior during file upload ... Please select the document type ... <input type= "file" class = "custom-file-input" id= ...
Read more >
Javascript – IE Input type text weird behavior – iTecNote
Javascript – IE Input type text weird behavior. htmlinternet-explorerjavascript. I have a google suggest like utility on my page. It automatically fills a ......
Read more >
Input type="file" showing weird behavior when used along ...
You are directly trying to mutate the state, productPicture=URL.createObjectURL(e.target.files[0]) which is wrong. Here you are not setting state. To set actual ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found