Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does html5 read local files

Shulou Source: shulou.com Published: 2022-05-31 13:03:29 10月05日 Update

This article mainly introduces the html5 how to read the local file related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this html5 how to read the local file article will have a harvest, let's take a look.

The code is as follows:

Add Picture

In terms of style, the input box of the input element should not be displayed. At this time, you need to set the input to a transparent style, and then cover it over the button element before you can click button to upload the picture. If accepted is set to "image/*", only image files are allowed to upload.

The Css style is as follows

.addpic {position:relative; margin-left:100px; width:95px; height:30px;} .addlogo {background: none repeat scroll 00 rgba (0,0,0,0); cursor: pointer; font-size: 30px; opacity: 0; position: absolute; right: 0; top: 0; z-index: 10;} js code is as follows: function readFiles (evt) {var files=evt.target.files; if (! files) {console.log ("the file is invaild"); return;} for (var item0, file) File=files [I]; iTunes +) {var imgele=new Image (); var thesrc=window.URL.createObjectURL (file); imgele.src=thesrc; imgele.onload=function () {$("# showlogo"). Attr ("src", this.src);} $(document) .ready (function () {$("# logoimg") .change (function (e) {readFiles (e)});}); this is the end of the article on "how html5 reads local files". Thank you for reading! I believe you all have a certain understanding of "how to read local files in html5". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Documents codes pictures styles knowledge elements content articles value easy to operate articles easy to understand more read industry information channels channels learning input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Shulou Tech Info Shulou Information Huawei