I made a photoalbum for this site i'm buiding and during our testing, we found that some JPEG's will not upload. For example, when we right click on a picture, look at it's properties and photo's of type Mozilla JPEG image file will not upload. Instead, the user gets an error stating it's not in JPEG format.
I'll include some code below and maybe you can see something I can't. Thanks for your help.
<?PHP
//defines location
$filedir = "c:/phpweb/userpics";
$picdir = "/userpics";
//check for jpeg image type
if($fupload_type =="image/pjpeg")
{
//copies picture to new directory and renames to username
if(copy($fupload,"$filedir/$CUserName.jpg"))
{
print ("<B>Hey Goodlooking! Your picture has been uploaded correctly</b><BR><BR>");
print "<table border=1>
<TR>
<TD height=\"300\" width=\"300\" align=\"center\">";
print ("<img src=\"$picdir/$CUserName.jpg\">");
print"</td>
</tr></table>";
print "<BR><B><a href=\"memberprofile.php?$PHPSESSID\">Home</a></b>";
print " <B><a href=\"fupload.php\">Upload again</a></b><BR>";
//adds 'yes' to database so user can search only profiles with pictures.
$query="UPDATE clients SET CPicture='yes' WHERE CUserName='$CUserName'";
//FAILED PROCESS
if(!mysql_query($query))
{
print "A process has failed during the update. Please report this incident to the Web Master <a href=\"mailto:mjyuen@hotmail.com\">mjyuen@hotmail.com</a><BR><BR>";
print "<BR><B><a href=\"memberprofile.php?$PHPSESSID\">Home</a></b>";
return false;
}
return true;
}
die ("Error in uploading. Please try again");
}
else
{
//PRINTS IF PICTURE IS ANYTHING BUT JPEG FORMAT
print "<b>ERROR:</b> Photo is not in JPEG format.<BR>
In order to show off your qualities to the fullest extent.<BR> LDSAlberta.com currently only acceptes pictures in JPEG format which have the highest color quality and in turn show you off the best!<BR>
<BR>
If you are having difficulties uploading your picture and sure that your photo is in jpeg format. Please email the <a href=\"mailto:mjyuen@hotmail.com\">Web Master</a> and attach the photo your are trying to upload.";
print "<BR><B><a href=\"memberprofile.php?$PHPSESSID\">Home</a></b>";
print " <B><a href=\"fupload.php\">Upload again</a></b><BR>";
}
unlink($fupload);
mysql_close();
?>