Ok, here goes. I have a script that resizes huge images (I got that part) however, I want to use the same code to resize the same uploaded image into thumbnails as well. However, that code doesn't resize the image and copy it into the regular pics folder, AND THEN copy it into the pics folder with a "thumbnail-" prefix. It does one or the other. How can I make it do both?
Here's the code
$dir = $pic_upload_dir; //defined in another file
$max = 100000;
$allowed=array("jpg");
$files_name = (str_rand(7, '123456789').".jpg"); //defined in another file. creatues a random filename
if (($width > $pic_w) || ($height > $pic_h)) {
//---resize start---//
$filename = $_FILES['file_field_main']['tmp_name'];
$width = 379;
$height = 281;
header('Content-type: image/jpeg');
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, $_FILES['file_field_main']['tmp_name']);
//---resize end---/
}
header("Location: index.php");
move_uploaded_file($_FILES['file_field_main']['tmp_name'], $dir."/".$files_name);
Now I also want it to create another file, the thumbnail file which should be 75x56px ($dir."/thumbnail-".$files_name).
Any help would be appreciated. Thanks.