- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML5 display as image rather than “choose file” button
Use the JavaScript FileReader to allow users to choose an image.
Let us see an example −
<form id = "myform" runat = "server"> <input type = 'file' id = "myimg" /> <img id = "myid" src = "#" alt = "new image" /> </form>
Here is the JS −
function readURL(input) { if (input.files && input.files[0]) { var r = new FileReader(); r.onload = function (ev) { $('#myid).attr('src', ev.target.result); } reader.readAsDataURL(input.files[0]); } }
Advertisements