Reputation: 55
hy users
I try to get the path of a file via html5 js
I try:
jQuery("#pfad").change(function(evt){
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
for (var i = 0; i < files.length; i++) {
alert(files[i].path);
}
but path isn't a attribute of this file object.... what can i do?
Upvotes: 1
Views: 1301
Reputation: 193261
You can't get the full file path due to security limitations. However you can read the name of the file:
jQuery("#pfad").change(function (evt) {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
for (var i = 0; i < files.length; i++) {
console.log(files[i].name);
}
});
Upvotes: 1
Reputation: 1045
Most browsers dont allow to get the full file path on client side. But in case of Google Chrome and Mozilla Firefox you can get the path by:
jQuery("#pfad").change(function(evt){
var path = $(this).val();
alert(path);
}
I tested it on both of these browsers.
Upvotes: 0