HTML5 reads local file sample code_html5 tutorial skills
WBOY
Release: 2016-05-16 15:47:59
Original
1667 people have browsed it
The html structure style is as follows:
Copy code
The code is as follows:
In terms of style, the input box of the input element should not be displayed. In this case, the input needs to be set to a transparent style, and then covered over the button element. Only then can the button be clicked to upload the image. . Set accepted to "image/*" to allow only image files to be uploaded.
function readFiles(evt){ var files=evt.target.files; if(!files){ console.log("the file is invalid"); return; } for(var i=0, file; file=files[i]; i ){ var imgele=new Image(); var thesrc=window.URL.createObjectURL(file); imgele.src=thesrc; imgele.onload=function(){ $("#showlogo ").attr("src",this.src); } } }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn