Okay, I uploaded the htaccess file to my root directory. I added the code (below) but I have so many errors (below) I don't quite know where to start. It is providing as file called u0v0.jpg - not sure where that came from - I know the directory exists. Can you explain a little more?
Code: Select all
// Where the uploadedfile is going to be placed
// $img_base = base directory structure for thumbnail images
// $w_dst = maximum width of thumbnail
// $h_dst = maximum height of thumbnail
// $n_img = new thumbnail name
// $o_img = old thumbnail name
function convertPic($img_base, $w_dst, $h_dst, $n_img, $o_img)
{ini_set('memory_limit', '100M'); // handle large images
unlink($img_base.$n_img); // remove old images if present
unlink($img_base.$o_img);
$new_img = $img_base.$n_img;
$file_src = $img_base."img.jpg"; // temporary safe image storage
unlink($file_src);
move_uploaded_file($_FILES['Filedata']['tmp_name'], $file_src);
list($w_src, $h_src, $type) = getimagesize($file_src); // create new dimensions, keeping aspect ratio
$ratio = $w_src/$h_src;
if ($w_dst/$h_dst > $ratio) {$w_dst = floor($h_dst*$ratio);} else {$h_dst = floor($w_dst/$ratio);}
switch ($type)
{case 1: // gif -> jpg
$img_src = imagecreatefromgif($file_src);
break;
case 2: // jpeg -> jpg
$img_src = imagecreatefromjpeg($file_src);
break;
case 3: // png -> jpg
$img_src = imagecreatefrompng($file_src);
break;
}
$img_dst = imagecreatetruecolor($w_dst, $h_dst); // resample
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $w_dst, $h_dst, $w_src, $h_src);
imagejpeg($img_dst, $new_img); // save new image
unlink($file_src); // clean up image storage
imagedestroy($img_src);
imagedestroy($img_dst);
}
$p_id = (Integer) $_POST[uid];
$ver = (Integer) $_POST[ver];
$delver = (Integer) $_POST[delver];
convertPic("attachments/", 175, 230, "u".$p_id."v".$ver.".jpg", "u".$p_id."v".$delver.".jpg");
Errors: Warning: unlink(attachments/u0v0.jpg): No such file or directory in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 48
Warning: unlink(attachments/u0v0.jpg): No such file or directory in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 49
Warning: unlink(attachments/img.jpg): No such file or directory in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 53
Warning: getimagesize(attachments/img.jpg): failed to open stream: No such file or directory in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 56
Warning: Division by zero in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 57
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 71
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 73
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 74
Warning: unlink(attachments/img.jpg): No such file or directory in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 76
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 77
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/lfchur5/public_html/trainingcenter/mtcStudentPage.php on line 78