FileUpload value 屬性

定義和用法
value 屬性返回<input type="file"> 元素選擇的文件路徑和名稱(chēng)。
在IE, Google Chrome, Opera, Firefox,Safari瀏覽器的value 屬性返回選擇文件的假路徑名稱(chēng) 。
注意: 由于安全原因,這個(gè)屬性是只讀的。
語(yǔ)法
fileuploadObject.value
瀏覽器支持
所有主要瀏覽器都支持 value 屬性
實(shí)例
實(shí)例
顯示選擇的文件名稱(chēng):
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("fname").value;
alert(x);
}
</script>
</head>
<body>
<form>
Select a file to upload:
<input type="file" id="fname" size="50">
</form>
<button type="button" onclick="displayResult()">Display file path</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("fname").value;
alert(x);
}
</script>
</head>
<body>
<form>
Select a file to upload:
<input type="file" id="fname" size="50">
</form>
<button type="button" onclick="displayResult()">Display file path</button>
</body>
</html>
嘗試一下 ?

更多建議: