Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://plungjan.name/test/previewjq.html" rel="nofollow noreferrer"><strong>Demo</strong></a></p> <p>Tested on several browsers, Chrome, Fx, Safari 6 (could someone test 5?)</p> <p>Works on my IE8 on XP without any changes in settings but as @Gunasekaran mentions later on this page you may need to </p> <blockquote> <p>Open Tools->internet option-> security tab-> custom level - locate the setting "Include local directory path when uploading files to a server" and click on Enable.</p> </blockquote> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;Image preview&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; var blank="http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif"; function readURL(input) { if (input.files &amp;&amp; input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#img_prev') .attr('src', e.target.result) .height(200); }; reader.readAsDataURL(input.files[0]); } else { var img = input.value; $('#img_prev').attr('src',img).height(200); } $("#x").show().css("margin-right","10px"); } $(document).ready(function() { $("#x").click(function() { $("#img_prev").attr("src",blank); $("#x").hide(); }); }); &lt;/script&gt; &lt;!--[if IE]&gt; &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;style&gt; article, aside, figure, footer, header, hgroup, menu, nav, section { display: block; } #x { display:none; position:relative; z-index:200; float:right} #previewPane { display: inline-block; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;section&gt; &lt;input type='file' onchange="readURL(this);" /&gt;&lt;br/&gt; &lt;span id="previewPane"&gt; &lt;img id="img_prev" src="#" alt="your image" /&gt; &lt;span id="x"&gt;[X]&lt;/span&gt; &lt;/span&gt; &lt;/section&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <p>Looks like this in IE8 on XP:</p> <p><img src="https://i.stack.imgur.com/bxEwq.png" alt="Example"></p> <p>A newer method is <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL.createObjectURL" rel="nofollow noreferrer">createObjectURL</a> which I have not implemented</p> <p><em>Update</em> You will need to add an onclick to clear the file input if you want to allow the user to select the same image twice (onchange does not trigger then)</p> <p><a href="https://stackoverflow.com/questions/12030686/html-input-file-selection-event-not-firing-upon-selecting-the-same-file">HTML input file selection event not firing upon selecting the same file</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload