i have a simple webapp, with this piece of code :
$(document).on('drop', '#dropfile', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).css('border', '6px #6BFF38 solid'); //vert
var file = e.originalEvent.dataTransfer.files[0];
alert(file.name);
return false;
});
The "alert(file.name)" return just the name of the file. I know it's a usual question, but i didn't find the answer. How can i get the full path of the file instead of only the name ? Is there any parameter of the file to get it ?
Answer by : Alexander Zinchenko
Link : Get URL of resource that is drag-and-dropped on field
In Firefox you can use file.mozFullPath. However, this variable presents only in Firefox and don't work in Chrome or Safari.
Addendum :
Due to security reasons, a files path information is never exposed. Even mozFullPath does not return the full path of file.
From mozilla website description for mozFullPath : This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future
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