Hello,
I am trying to help someone with their website admin system that they had made back in 2009. When trying to add new items using this system, the new products did not have images like they used to. I traced the problem and realized that they weren’t even being uploaded to the FTP server. The people who made the website use the following function to upload the images. I am assuming the problem has to do with the fact that some of the code has been deprecated, as it was written for an earlier version of PHP. Just for reference the version of PHP currently installed on the website is PHP Version 5.3.8. Hopefully that explains the problem!
Here is the code:
[php]function upload_image($uploading_file, $uploaddir, $new_imagename)
{
// print_r($_FILES);
$thumb_path = $uploaddir."/thumb";
$thumb_img = $thumb_path . "/" .$new_imagename;
$display_path = $uploaddir."/display";
$display_img = $display_path . "/" .$new_imagename;
$message = "<br /><strong>Image Upload</strong>";
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if($_FILES[$uploading_file]['size'] >= MAXSIZE)
$error[$uploading_file] = "<br />The image file exceeds the limit.";
if(!isset($_FILES[$uploading_file]))
$error[$uploading_file] = "<br />An image was not found.";
$imagename = basename($_FILES[$uploading_file]['name']);
//echo $imagename;
if(empty($imagename))
$error[$uploading_file] = "<br />The name of the image was not found.";
if(empty($error))
{
$newimage = $uploaddir . "/" . $new_imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES[$uploading_file]['tmp_name'], $newimage);
// CONVERT IMAGE TO THUMB
if(is_dir($thumb_path))
exec ("convert $newimage -resize ".T_RESIZE_W."x".T_RESIZE_H." $thumb_img");
// CONVERT IMAGE TO DISPLAY
if(is_dir($display_path))
exec ("convert $newimage -resize ".RESIZE_W."x".RESIZE_H." $display_img");
if(empty($result))
$error["result"] = "<br />There was an error moving the uploaded file.";
}
if(!empty($error))
{
while(list($key, $val) = each($error))
{
$message .= "<br />Upload Failed because of the following $val";
}
} else {
$message .= "<br /> Uploaded Successfully";
}
return $message;
}
[/php]
Thank you very much for your assistance, and btw I am NOT getting paid to do this, I am helping a family member for free, or at least trying to help lol.
-Mike