127
rated 0 times
[
130]
[
3]
/ answers: 1 / hits: 60960
/ 14 Years ago, thu, november 4, 2010, 12:00:00
I want to preview an image before uploading it to the server. I have written a little bit code for it, but it is only being previewed in Internet Explorer, not in other browsers like Safari, Chrome, Firefox, due to some type of security reasons. Is there any solution to preview the image in these browsers?
<body>
<form name=Upload enctype=multipart/form-data method=post>
Filename: <INPUT type=file id=submit>
<INPUT type=button id=send value=Upload>
</form>
<div
id=div
align=center
style=height: 200px;width: 500px;border-style: ridge;border-color: red>
</div>
</body>
<script type=text/javascript>
var img_id=0
var image = new Array()
document.getElementById('send').onclick=function()
{
img_id++
var id=imgid+img_id
image = document.getElementById('submit').value;
document.getElementById('div').innerHTML=<img id='+id+' src='+image+' width=500px height=200px>
}
</script>
</html>
More From » javascript