If I have a
<input id="uploadFile" type="file" />
tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user.
In FF, I just do:
var selected = document.getElementById("uploadBox").files.length > 0;
But that doesn't work in IE.
length property to check file is selected or not. If element. files. length property returns 0 then the file is not selected otherwise file is selected.
Try document. getElementById("FileUpload1"). value this value should have a path for a file to be uploaded, just strip all dirs from that value and you will have file name.
This works in IE (and FF, I believe):
if(document.getElementById("uploadBox").value != "") { // you have a file }
this piece of code works in my local environment, hope it will also works in live
var nme = document.getElementById("uploadFile"); if(nme.value.length < 4) { alert('Must Select any of your photo for upload!'); nme.focus(); return false; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With