I know the structure of the code is probably not great but i cant seem to find out why it wont work.
$subimgfile is the variable name for $_FILES['imgfile']['name']
and $subimgfiletype is the variable name for $_FILES['imgfile']['type']
Expand|Select|Wrap|Line Numbers
- if ($subimgfile)
- {
- $uploaddir = "./product_images";
- if (($subimgfiletype != "image/gif") && ($subimgfiletype != "image/jpeg") && ($subimgfiletype != "image/pjpeg"))
- {
- $form->setError($field, "* Image Must be .jpg / .jpeg or .gif, your file had extension $subimgfiletype");
- unlink($subimgfile);
- }
- $imgsize = GetImageSize($subimgfile);
- if (($imgsize[0] > 531) || ($imgsize[1] > 398))
- {
- $tmpimg = tempnam("/tmp", "MKUP");
- system("djpeg $subimgfile >$tmpimg");
- system("pnmscale -xy 531 398 $tmpimg | cjpeg -smoo 10 -qual 80 >$subimgfile");
- unlink($tmpimg);
- }
- $final_filename = str_replace(" ", "_", $subimgfile);
- $FileCounter = 1;
- while (file_exists( 'product_images/'.$final_filename ))
- $final_filename = $FileCounter++.$final_filename;
- $newfile = $uploaddir . "/$final_filename";
- if (!copy($subimgfile,"$newfile"))
- {
- $form->setError($field, "* Error uploading file");
- }
- unlink($subimgfile);
- }