Search
 
SCRIPT & CODE EXAMPLE
 

HTML

input type="file" and display image

<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

load image file from input in html

function onFileSelected(event) {
  var selectedFile = event.target.files[0];
  var reader = new FileReader();

  var imgtag = document.getElementById("myimage");
  imgtag.title = selectedFile.name;

  reader.onload = function(event) {
    imgtag.src = event.target.result;
  };

  reader.readAsDataURL(selectedFile);
}
Comment

input file img / input file image

<div class="image-upload">
  <label for="file-input">
    <img src="https://icons.iconarchive.com/icons/dtafalonso/android-lollipop/128/Downloads-icon.png"/>
  </label>

  <input id="file-input" type="file" />
</div>


 // CSS

.image-upload>input {
  display: none;
}
Comment

PREVIOUS NEXT
Code Example
Html :: html syntax 
Html :: how to create bold text in html 
Html :: bootstrap 5 card simple 
Html :: input datetime without time 
Html :: Simple random code generator 
Html :: HTML <mark Element 
Html :: how to choose your html website favicon 
Html :: razor view partial view 
Html :: js input just audio files 
Html :: html special characters 
Html :: using bootstrap toast in mvc view 
Html :: html acronym 
Html :: fieldset margin 
Html :: html code for text link new window 
Html :: Combining <symbol with <use SVG tags on a HTML page 
Html :: vuejs conditional rendering paragraph not working 
Html :: thymeleaf for each limit size 
Html :: Links do not have a discernible name 
Html :: owlcarousel 
Html :: common web server ports 
Html :: link node module in html 
Html :: Best Carousel Slider For BootStrap HTML5 
Html :: iframe messaging 
Html :: ionic footer not appearing 
Html :: react-burger-menu right 
Html :: require is not define on html script 
Html :: signature: Generated signature does not match submitted signature. 
Html :: tailwind css breadcrumbs 
Html :: npm html-pdf 
Html :: html ol vs ul 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =