Use HTML5 File to convert base64 to images_html5 tutorial skills
I have just come across the concept of inline images. Even if the image file is encoded into base64 for inline images, look at the code below to see the inline problem.
It can reduce http requests, but the disadvantage is that it cannot be cached across domains!
Then how to convert pictures to base64 online
If you only rely on simple javascript, there is js with permission issues does not allow operations on local files or folders for security reasons
Now that HTML5 is here, there is a lot of information on Baidu, including Chinese and w3c documents http://www. w3.org/TR/FileAPI/
Now we use the readAsDataURL function in the file api of html5. This is a function that converts the file into base64 encoding
<script> <br>window.onload = function(){ <br>var input = document.getElementById("demo_input") ; <br>var result= document.getElementById("result"); <br>var img_area = document.getElementById("img_area"); <br>if ( typeof(FileReader) === 'undefined' ){ <br>result.innerHTML = "Sorry, your browser does not support FileReader, please use a modern browser! "; <br>input.setAttribute( 'disabled','disabled' ); <br>} else { <br>input.addEventListener( 'change',readFile,false );} <br>} <br>function readFile (){ <br>var file = this.files[0]; <br>//Here we judge the type. If it is not an image, return it and remove it. Then you can upload any file <br>if(!/image/w /.test (file.type)){ <br>alert("Please make sure the file is of image type"); <br>return false; <br>} <br>var reader = new FileReader(); <br>reader.readAsDataURL( file); <br>reader.onload = function(e){ <br>result.innerHTML = '<img src="' this.result '" alt=""/>'; <br>img_area.innerHTML = '<div class="sitetip">Image img tag display: </div><img src="' this.result '" alt=""/>'; <br>} <br> } <br></script>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.
