View Full Version : Upload the same file
Rain Lover
06-08-2014, 05:22 AM
You cannot select and upload the same file except in Firefox, which mistakenly allows you to do so:
<input type="file" id="fileChooser">
document.getElementById('fileChooser').onchange = function () {
alert('Uploaded!');
};
Here (http://jsfiddle.net/scMF6/2/)'s my approach to resolve the issue. I wonder if there's a neater way to achieve it.
jscheuer1
06-08-2014, 02:38 PM
I don't get it:
I thought file inputs were off limits to javascript.
Even if this fires onchange, then wouldn't it be a different file?
Server side code used to process the upload would be a better place to weed out duplicates, right?
Rain Lover
06-08-2014, 05:26 PM
I thought file inputs were off limits to javascript.
Thanks to HTML5 File API (http://dev.w3.org/2006/webapi/FileAPI/) now we can even read a file content with JavaScript: demo (http://jsfiddle.net/Mori/tJBHZ/).
I don't get it
Sorry if the question isn't very clear!
I mean you cannot re-select the same file twice in a row, i.e. you select and upload foo.txt on your desktop, for example, and then click the file chooser again, file select dialog appears and you try to select the same file again -- the browser simply does nothing and no alert box appears.
jscheuer1
06-09-2014, 12:58 AM
OK, obviously I haven't been messing around with this much lately. Perhaps the rules have changed. Anyways, if that works, then it's fine. Does it?
Rain Lover
06-09-2014, 01:04 AM
Anyways, if that works, then it's fine. Does it?
Yes, it seems to be working with no problem.
Thanks, anyway!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.