1<!DOCTYPE html> 2<meta charset="utf-8"> 3<title>FileAPI Test: Creating Blob URL with File as image source</title> 4<link rel="author" title="Intel" href="http://www.intel.com"> 5<link rel="author" title="JunChen Xia" href="mailto:xjconlyme@gmail.com"> 6 7<div> 8 <p>Test steps:</p> 9 <ol> 10 <li>Download <a href="/images/blue96x96.png">blue96x96.png</a> to local.</li> 11 <li>Select the local file (blue96x96.png) to run the test.</li> 12 </ol> 13 <p>Pass/fail criteria:</p> 14 <p>Test passes if there is a filled blue square.</p> 15 16 <p><input type="file" accept="image/*" id="fileChooser"></p> 17 <p><img id="displayImage"></img></p> 18</div> 19 20<script> 21 var fileInput = document.querySelector("#fileChooser"); 22 var img = document.querySelector("#displayImage"); 23 24 fileInput.addEventListener("change", function(evt) { 25 img.src = window.URL.createObjectURL(fileInput.files[0]); 26 }, false); 27</script> 28 29