Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to display uploaded image in html using javascript

<p><input type="file"  accept="image/*" name="image" id="file"  onchange="loadFile(event)" style="display: none;"></p>
<p><label for="file" style="cursor: pointer;">Upload Image</label></p>
<p><img id="output" width="200" /></p>

<script>
var loadFile = function(event) {
	var image = document.getElementById('output');
	image.src = URL.createObjectURL(event.target.files[0]);
};
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: To install the latest version of React: 
Javascript :: javascript clear text in textarea 
Javascript :: setup ejs views directory in express 
Javascript :: javascript shuffle an array 
Javascript :: jquery count elements 
Javascript :: react map array limit 
Javascript :: dom is loaded 
Javascript :: error: bundling failed: Error: Unable to resolve module react-native-community/toolbar-android 
Javascript :: html get selected option javascript 
Javascript :: discord.js create unexipable invite 
Javascript :: useeffect umnount 
Javascript :: js reverse array loop 
Javascript :: jquery remove all tr from table 
Javascript :: order datatable 
Javascript :: jquery varable exists 
Javascript :: jquery loop through list element 
Javascript :: remove whitespace with regex javascript 
Javascript :: create an array of numbers by numbers range in angular 
Javascript :: js check file exist 
Javascript :: how to run react build locally 
Javascript :: math random 0 to 100 
Javascript :: uniqid js 
Javascript :: javascript capitalize first letter 
Javascript :: angular form set value without fire event 
Javascript :: convert binary to decimal javascript 
Javascript :: how to append to file in js 
Javascript :: js get all select options 
Javascript :: missing from-clause entry for table sequelize limit 
Javascript :: javascript add adjacent html 
Javascript :: js remove undefined from object 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =