欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript 獲取表單file全路徑

 更新時(shí)間:2009年12月31日 20:16:49   作者:  
在ie6中對(duì)于<input type="file" />通過obj.value是可以獲取客戶端選擇文件的全路徑的,但是到ie7就只能獲取文件名,這對(duì)于onchange事件立即顯示圖片會(huì)有問題,可以用js方法解決
具體代碼如下:
復(fù)制代碼 代碼如下:

<html>
<head>
<title>get file input full path</title>
<script language='javascript'>
function getFullPath(obj)
{
if(obj)
{
//ie
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
obj.select();
return document.selection.createRange().text;
}
//firefox
else if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
if(obj.files)
{
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
</script>
</head>
<body>
<input type="file" onchange="document.getElementById('img').src=getFullPath(this);" />
<img id="img" />
</body>
</html>

相關(guān)文章

最新評(píng)論