M. Ozn
M. Ozn

Reputation: 1220

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 ?

Upvotes: 3

Views: 3981

Answers (1)

zaffer
zaffer

Reputation: 446

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

Upvotes: 2

Related Questions