因為要抓主機的檔案路徑,IE的安全性設定要改一下
會轉短路徑
範例是參考MSDN上的修改而成
http://msdn.microsoft.com/en-us/library/tes8ehwe(v=vs.84).aspx
=========================HTML CODE==========================
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/jscript">
function showfilename() {
var x = document.getElementById("File1").value;
// alert(ShowShortPath(x));
TextArea1.value = ShowShortPath(x);
}
function ShowShortPath(filespec) {
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filespec);
s = "short path : " + f.ShortPath;
return (s);
}
</script>
</head>
<body>
<input id="File1" type="file" /><input id="Button1" type="button" value="秀短名稱" onclick="showfilename()"/>
<br />
<textarea id="TextArea1" cols="80" name="S1" rows="2"></textarea>
</body>
</html>
沒有留言:
張貼留言