Replies Back to Article

Preview Image with File Field

Useful but limited
December 20, 2002 by Andi Fenner
This is a really handy tutorial however the preview doesn't appear to work on a form that has multiple file upload fields.  This would be a good feature
Ooops
December 20, 2002 by Andi Fenner

I take it all back!  All I had to do was change the file in the on click Event

Sorry

Setting the Titel fot the pop-up page
July 21, 2003 by Jelle-Jacob de Vries

How can set the titel for the pop-up page instead of URL form the previous page it is now using? 

RE: Setting the Titel fot the pop-up page
July 21, 2003 by Marcellino Bommezijn
Just look at the code where it says; popup.document.writein and add the tags for the page title in html code.
RE: RE: Setting the Titel fot the pop-up page
July 22, 2003 by Jelle-Jacob de Vries
Thanks a lot!
syntax typo in popup=
September 28, 2006 by m Trimmell

This has a syntex typo preventing the code to run correctly.  I changed the syntex to....popup = window.open("'imagePreview', width="600," height="450," left="100," top="75," screenx="100," screeny="75," scrollbars, location, menubar, status, toolbar, resizable="1"");

But I'm still not getting the picture to view in the preview window.  Any thoughts on this?

//create the popup
popup = window.open('', 'imagePreview', )width=600,height=450,left=100,top=75,
screenX=100,screenY=75,scrollbars,location,menubar,status,toolbar,resizable=1');

Resolved - RE: syntax typo in popup=
September 28, 2006 by m Trimmell
Here is the correct syntax: I took some time since I'm not saavy about JavaScript, but I figured it out. besides the the bracket in the wrong place, when I copy pasted the script from this site the l's in writeln became i's... Even so, I learned a new JavaScript command and that is writeln, which can be considered comperable to echo in the php world.. Nice script!
RE: Resolved - RE: syntax typo in popup=
September 28, 2006 by m Trimmell
//
RE: RE: Resolved - RE: syntax typo in popup=
September 28, 2006 by m Trimmell
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 an image."); document.form1.file.focus(); }else{ //create the popup popup = window.open("", "imagePreview", "width=600, height=450, left=100, top=75, screenX=100, screenY=75, scrollbars, location, menubar, status, toolbar, 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 from list above write URL to file popup.document.writeln("" + filename + ""); popup.document.writeln(""); popup.document.close(); popup.focus(); } }