<input type="file" name="file1" style="width:300'" class="tx1" value="" onchange="PreviewImg(this);">
<div style="width:400px;height:300px;border:1px solid #aaaaaa;overflow:auto" id="previewDiv">
</div>
<script language="javascript">
function PreviewImg(obj){
var div = document.getElementById("previewDiv");
if(obj.value=="" || div.childNodes.length>0){
div.removeChild(div.firstChild);
if(obj.value=="")return;
}
var ext = obj.value.substring(obj.value.lastIndexOf(".")+1)
div.appendChild(getFlash(obj.value,ext));
}
function getFlash(src,ext){
var img;
switch(ext.toLowerCase()){
case "jpg":
case "jpeg":
case "bmp":
case "gif":
case "png":
img = document.createElement("img");
break;
case "swf":
img = document.createElement("embed");
img.type="application/x-shockwave-flash";
img.width=400;
img.height=300;
break;
}
img.src=src;
return img;
}
</script>