javascript File對象

File對象 測試html爲1231231.html 記得試試一次傳多個文件html

http://www.cnblogs.com/oneword/archive/2009/06/09/1499273.html 參考這個jquery

作了個小demo打印出files信息數組

<body>
<input type="file" multiple="multiple" id="files" name="files" />
<button id="mybtn">點擊</button>
<script src="jquery-1.12.3.js"></script>
<script>
$(function(){
	$("#mybtn").on("click",function(e){
		var files = document.getElementById("files");
		console.log(files.files);
	});
});
</script>
</body>

input元素添加了屬性multiple屬性,意爲能夠單次上傳多個文件,打印出的files即表明上傳的文件(可多個)的信息; 例如上傳兩個圖片,返回一個數組,該數組含有兩個圖片的信息 其中type,size,name是比較重要的屬性,分別爲該文件的類型,大小和文件名測試

相關文章
相關標籤/搜索