Hmmmm. That's verry interesting. I thought at first that it could be in uppercase, but the toLowercase method takes care of that. Can you send me the file directly so I can play with it. My email is below my name.
Haden Pike Email: haden.pike@xxxxxxxxx -------------------------------------------------- From: "Alex Hall" <mehgcap@xxxxxxx> Sent: Friday, July 03, 2009 9:40 PM To: <programmingblind@xxxxxxxxxxxxx> Subject: e: he simplest things... JS trouble!
The file extension is gotten correctly, but even if it is jpg, the error message comes up.Have a great day, Alex----- Original Message ----- From: "Haden Pike" <haden.pike@xxxxxxxxx To: <programmingblind@xxxxxxxxxxxxx Date sent: Fri, 3 Jul 2009 21:04:02 -0400 Subject: Re: he simplest things... JS trouble!What appears in the message as the file type? Haden Pike Email: haden.pike@xxxxxxxxx-------------------------------------------------- From: "Alex Hall" <mehgcap@xxxxxxx Sent: Friday, July 03, 2009 8:52 PM To: <programmingblind@xxxxxxxxxxxxx Subject: he simplest things... JS trouble!Hi all, I am trying to make a page that lets the user browse their computer for an image file, select it (through the use of a "file" input type), then the page will display a thumbnail of that picture via resizing using the img tag's length and width parameters. However, my basic error-checking to ensure that the file is actually an image is not letting anything through. I break the path in the "file" field by periods and then get the final element of the resulting array, which is the file's extension. I ensure that it is an appropriate extension (jpg or png for now). If so, I add the thumbnail to a dynamically updated area on the page. If not, nothing else happens except the user is informed of their mistake. However, even if theuserpicks a jpg, the error message pops up. Why? Below is my function. As always, my bn will strip out some punctuation, so ignore errors in quotes, braces, parentheses, and so on.file=f.pic.value.split(".") //get path, converting to array split by periods ext=file[file.length-1].toLowerCase(); //get extension and lowercase it if(ext!="jpg" || ext!="png"){ //if ext is not valid image filetype alert("You have selected an unsupported filetype (."+ext+"). Please select only .jpg or .png files.");else{ //file ok, so add to thumbnail area preview=document.getElementById("pics"); sofar=preview.innerHTML; //any images already displayed, so they will not be erased by this most recent one, but added to instead newpic="<img src='"+f.pic.value+"' height='100' width='100'></img><br>"; //latest img, source is the path the user chose preview.innerHTML=sofar+newpic; //add new file as thumbnail to any already there alert("okay, you can pick a new image now."); //test for me to ensure it completes all the dhtml and exitscatch(e){ alert(e+" in addpic(): "+e.description);Have a great day, Alex __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind