image preview in javascript
<p>The following code doesn't work in Firefox and Chrome but works in IE. Can anyone tell me why it doesn't work in browser except IE with solution. Thanks in advance.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
function hello()
{
    var a=document.getElementById("upload").value;
    alert(a);
    document.getElementById("previewIMG").src=a;
    document.getElementById("previewIMG").style.display="block";
}

&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form name="img"  enctype="multipart/form-data"&gt;
&lt;input type="file" name="upload" id="upload" /&gt;
&lt;input type="button" name="submit" value="Upload Me Now" onClick="javascript:hello();"&gt;
&lt;img id="previewIMG" src="" style="display:none;" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
