Display Image after selecting image before uploading - PHP

If you want to show image when you select image for uploading, before uploading you will be able to see the image that you are going to upload. Below is the descriptive code to do this task.


First Create HTML Code that contains image upload input field.

<!DOCTYPE html>
<link class="jsbin" href="" rel="stylesheet" type="text/css" />
<script class="jsbin" src=""></script>
<script class="jsbin" src=""></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src=""></script>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
  <input type='file' onchange="readURL(this);" />
    <img id="blah" src="#" alt="your image" />


Now Insert Javascript Code onto Same page in between head tags </head> .... </head>

Javascript Code


function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function (e) {