最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Absolute path to file on input[type=file] - Stack Overflow

programmeradmin0浏览0评论

Is is possible to get the ABSOLUTE path to a file using JavaScript or jQuery? These are my trials so far but the closest I can get is just the filename.

    var filepath = $('input[type=file]').val();
    var test = this.files;
    var test2 = test[0];
    var test3 = test2.fileName;
    var test4 = test2.filePath;
    var test5 = test2.Name;
    var h = imageInput.value;
    var b = document.getElementById("AcademicPhotoId");
    var l = b.value;
    var binary = b.getAsBinary();
    $('.image-display img').attr('src', filepath);

Is is possible to get the ABSOLUTE path to a file using JavaScript or jQuery? These are my trials so far but the closest I can get is just the filename.

    var filepath = $('input[type=file]').val();
    var test = this.files;
    var test2 = test[0];
    var test3 = test2.fileName;
    var test4 = test2.filePath;
    var test5 = test2.Name;
    var h = imageInput.value;
    var b = document.getElementById("AcademicPhotoId");
    var l = b.value;
    var binary = b.getAsBinary();
    $('.image-display img').attr('src', filepath);
Share Improve this question edited Dec 5, 2022 at 22:26 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jul 28, 2011 at 22:00 HoBaHoBa 3,6046 gold badges27 silver badges33 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

No, that would be a security violation. (It could tell you the user's name, etc. i.e. c:\Users\Kirk\Desktop\uploadedfile.txt)

Out of curiosity, why do you desire this information?

According to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is c:\fakepath

发布评论

评论列表(0)

  1. 暂无评论