A
Anonymous
Guest
Here is what I have to verify the image extension. I just want to make sure the file that is being uploaded in a .jpg image and not anything else. Only jpegs.
Remember also that $image contains the path to the image on their computer. Came from a form. When I use this it always says it's not a jpeg file even when it is.
Any hints?
Code:
if ( ($image) && ($image != "") ) {
$type = basename($image_type);
switch ($type) {
case "jpeg":
case "jpg": $filename = "Images/$prodname.jpg";
copy ($image, $filename);
$sql = "update ctlg_products
set image = '$filename'
where prodname = $prodname";
$iresult = @mysql_query($sql);
if (!$iresult) {
echo "There was a database error when executing <PRE>$sql</PRE>";
echo mysql_error();
exit;
}
break;
default: echo "Invalid picture format: $image_type";
}
}
if (!$result)
return false;
else
return true;
}
Remember also that $image contains the path to the image on their computer. Came from a form. When I use this it always says it's not a jpeg file even when it is.
Any hints?