<p> <label>请选择一个文件:</label> <input type="file" id="file" multiple="multiple" onchange="readAsDataURL()"/> </p> <div id="result" name="result"></div>
<script>
var result=document.getElementById("result"); var file=document.getElementById("file"); function readAsDataURL(){ var file = document.getElementById("file").files; var result=document.getElementById("result"); for(i = 0; i< file.length; i ++) { var reader = new FileReader(); reader.readAsDataURL(file[i]); reader.onload=function(e){ //多图预览 result.innerHTML = result.innerHTML + '<img src="' + this.result +'" alt="" />'; } } } </script>