function previewImage(fileInfo) { var filename = ''; //create the path to your local file if (fileInfo == null) { if (document.form1.file != "") { filename = "file:///" + document.form1.file.value; } } else { filename = fileInfo; } //check if there is a value if (filename == '') { alert ("Please select a image."); document.form1.file.focus(); } else { //create the popup popup = window.open('','imagePreview','width=640,height=100,left=100,top=75,screenX=100,screenY=75,scrollbars,location,menubar,status=0,toolbar=0,resizable=1'); //start writing in the html code popup.document.writeln("
"); //get the extension of the file to see if it has one of the image extensions var fileExtension = filename.substring(filename.lastIndexOf(".")+1); if (fileExtension == "jpg" || fileExtension == "jpeg" || fileExtension == "gif" || fileExtension == "png") popup.document.writeln(""); else //if not extension fron list above write URL to file popup.document.writeln("" + filename + ""); popup.document.writeln(""); popup.document.close(); popup.focus(); } }