【发布时间】:2017-06-22 03:16:14
【问题描述】:
我在尝试获取 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>
当我按下按钮时,文本字段会显示这个
C:\fakepath\ART.pdf
我尝试编辑 Internet Explorer 设置,它工作正常,但我无法在 chrome 上获得完整路径 有什么方法可以获取 chrome 上的完整路径吗?谢谢
【问题讨论】:
-
为什么需要路径?
-
允许用户选择要保存一些文件的目录
-
出于明显的安全原因,您无法访问它。您希望任何网站都能看到您的目录结构吗?
-
基本上是chrome,因为我的icefaces项目在ie中效果不佳。
标签: javascript html google-chrome