So background is I need to create a file upload control that submits files in a very specific fashion. Most users are on IE8 so I using a hidden iframe and a form post, but when the user selects the file using the file input my function kicks off. I don't know how to retrieve just file name in IE8 since the file api is not supported. In the example below the alert will output the full address, but this is not useful to me. Any ideas?
<form>
<input name="data" id="filesInput" onchange="handleFileSelect(this);" type="file" value=""/>
</form>
function loadFile(evt){
alert(evt.value);
}
Doesn't evt.value contain the full filename, but having a fake path, something like
C:\fakepath\video.mp4
So, can you use:
var n = evt.target.value.substring(evt.target.value.lastIndexOf('\\') + 1);
Now n will contain just the filename.
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