如何从输入类型文件获取完整的文件路径

如何从输入类型文件获取完整的文件路径

本文介绍了如何从输入类型文件获取完整的文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从输入类型文件中获取完整的文件路径?

Hi,
how to get full file path from input type file?

推荐答案

When a file is selected by using the input type=file object, the value of the value property depends on the value of the "Include local directory path when uploading files to a server" security setting for the security zone used to display the Web page containing the input object.

The fully qualified filename of the selected file is returned only when this setting is enabled. When the setting is disabled, Internet Explorer 8 replaces the local drive and directory path with the string C:\fakepath\ in order to prevent inappropriate information disclosure.





在我所知道的所有其他当前主流浏览器中,它也被关闭了。文件名是你能得到的最好的。



In all other current mainstream browsers I know of, it is also turned off. The file name is the best you can get.


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function showFileName() {
   var fil = document.getElementById("myFile");
   alert(fil.value);
}
</script>
</head>
<body>
<form id="frmMain" name="frmMain">
    <input type="file" id="myFile" name="myFile"/>
    <a href="#" onclick="showFileName()">Show Name</a>
</form>
</body>
</html>



注意 出于安全考虑,大多数浏览器只返回文件名,而不是完整路径和文件名。 IE6及以下浏览器将返回所需的值



问候,


NoteFor security reasons most of the browser's will only return the file name and not the full path and file name. IE6 and below browsers will return you the desired value

Regards,


这篇关于如何从输入类型文件获取完整的文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:54