简体   繁体   English

如何使用Javascript从文件上传获取完整路径

[英]how to get full path from fileupload using Javascript

I need to know how to get full path from fileupload using javascript,我需要知道如何使用 javascript 从文件上传中获取完整路径,

I tried using the following coding but of no use我尝试使用以下编码但没有用

<input type="file" id="picField" onchange="preview(this)">

<script type="text/javascript">

function preview(test){
    var source=test.value;
    alert(source);
}
</script>

but in the alert message, i am getting only但在警报消息中,我只收到

Filename.extension

I am not getting full path, but it is showing full path in File Upload box please help how to solve this problem我没有得到完整路径,但它在文件上传框中显示完整路径请帮助如何解决这个问题

Thanks谢谢

这是浏览器安全限制,在现代浏览器中,您无法获得所选文件的完整客户端文件系统路径,也无法以编程方式设置路径...

Maybe for security reason, javascript doesn't allow this to happen.也许出于安全原因,javascript 不允许这种情况发生。 And if you come to think of it, Server side pages cannot access your local files.如果您考虑一下,服务器端页面无法访问您的本地文件。 Not that I have a solution for your question.并不是说我对您的问题有解决方案。

Actually, there is some kind of solution.实际上,有某种解决方案。
Albeit, it will help only if you can run Electron desktop app on local machine: https://stackoverflow.com/a/59990858/9390914尽管如此,只有当您可以在本地机器上运行 Electron 桌面应用程序时才会有所帮助: https : //stackoverflow.com/a/59990858/9390914

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用javascript的文件上传完整路径 - full path from fileupload using javascript 如何使用 JavaScript 从完整路径获取文件名? - How to get the file name from a full path using JavaScript? 如何使用jQuery Fileupload获取用户type =“ file”的完整路径 - How to get full path to user's type=“file” using jQuery Fileupload 如何使用javascript中的输入类型文件获取文件的完整路径? - How to get full path of file using input type file in javascript? 如何从完整路径中获取文件名并存储在 Javascript 中的对象属性中? - How to get the filename from the full path and store in an object property in Javascript? 这有可能获得完整的客户端路径吗 <asp:FileUpload> 按钮? - Is this possible to get full client path in <asp:FileUpload> button? 使用JavaScript从完整路径获取不带GET参数的文件名? - Get the file name without GET parameters from a full path using JavaScript? Javascript:获取目录的完整路径 - Javascript: Get full path to a directory 如何使用javascript在Firefox和IE浏览器中浏览文件的完整目录路径? - How to get full directory path of the file on browse in Firefox and IE using javascript? 如何在更改时获取所选文件的完整路径<input type="‘file’">使用 javascript,jquery-ajax? - How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM