Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery on drop get full path name

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 ?

like image 979
M. Ozn Avatar asked May 25 '26 16:05

M. Ozn


1 Answers

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

like image 190
zaffer Avatar answered May 28 '26 05:05

zaffer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!