Javascript 在google chrome上获取文件路径

Javascript 在google chrome上获取文件路径,javascript,html,google-chrome,Javascript,Html,Google Chrome,在chrome上获取文件路径时遇到问题。这是我使用javascript函数编写的代码: <html> <head> <script language="javascript" type="text/javascript"> function getPath() { var inputName = document.getElementById('ctrl'); var imgPath; imgPath = inputName.value; //ale

在chrome上获取文件路径时遇到问题。这是我使用javascript函数编写的代码:

<html>
<head>
<script language="javascript" type="text/javascript">
function getPath() {
 var inputName = document.getElementById('ctrl');
 var imgPath;

 imgPath = inputName.value;
 //alert(imgPath);
 var x = document.createElement("INPUT");
x.setAttribute("type", "text");
x.setAttribute("value", imgPath);
document.body.appendChild(x);
}
</script>
</head>
<body>


<input type="file" name ="file1" id="ctrl" webkitdirectory directory multiple/>
<input type="submit" value="Enviar" onclick="getPath()"/>

</body>
</html>
我试着编辑internet explorer设置,效果很好,但我无法在chrome上获得完整路径
有没有办法在chrome上获得完整路径?谢谢

您正在使用多个和目录选项,因此您的路径将在inputName.files下可用

出于安全原因,这些将是相对路径。如果希望读取文件,则需要使用FileReader API


我在评论中看到,您正试图将文件保存到特定位置。这无法通过浏览器实现。您只需提供要下载的文件,用户就可以决定将其保存在何处。通常,它会保存到操作系统的默认下载文件夹中。

为什么需要该路径?要允许用户选择要保存某些文件的目录,出于明显的安全原因,您无法访问该目录。你想让任何网站都能看到你的目录结构吗?基本上是chrome,因为我的icefaces项目在ie中运行不好。但是fileReader API不能帮助我获得完整的路径。它还向我展示了fakepath
C:\fakepath\ART.pdf