preview image file upload javascript
<input type="file" accept="image/*" onchange="loadFile(event)">
<img id="output"/>
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
output.onload = function() {
URL.revokeObjectURL(output.src) // free memory
}
};
</script>function display(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(event) {
$('#myid').attr('src', event.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#demo").change(function() {
display(this);
});stackoverflow.com
Also in JavaScript:
- how to add all values of array together js
- remove first 3 characters from string javascript
- '{ state: any; dispatch: React.Dispatch<{ type: string; payload: any; }>; }' is not assignable to type 'Store'
- how to add carousel in javascript
- javascript does not equal
- javascript have special characters
- a open in new tab
- js math random
- Parallax.js wrapper for react
- ejs / javascript check if array/object exists and is not empty
- color text react native
- angular add bootstrap
- Sum of all the multiples of 3 or 5
- js for
- npm react native turn by turn navigation
- javascript check if key exists in object
- moment for react
- not equal to sign in js
- string to boolean javascript
- node.js
- create function javascript
- after load page jquery
- destruction in javascript
- javascript try catch finally