class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I'm trying to create a thumbnail and an image (resized if it is too large). I am using a different upload mechanism though, swfupload.org
This code worked when I called it with a regular form, however, I have only been able to get it to either create the thumbnail or just upload the image (and if its too big, it won't resize).
I tried using Clean() in there too, that didn't seem to help much. Here is the current code that will just produce two files of the original uploaded image (no resized thumbnail and no resized image)
$handle = new Upload($_FILES['Filedata']);
if ($handle->uploaded) {
$handle->image_convert = 'jpg';
// lets make some changes to the images (resize, etc)
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_ratio_no_zoom_in = true;
// Lets create a thumbnail! First width then height
if($handle->image_src_x > 75){
$handle->image_x = 75;
}
if($handle->image_src_y > 100){
$handle->image_y = 100;
}
// lets rename this file
$newfile = "$handle->file_src_name_body" . time();
$newfile_p = md5($newfile);
$newfile_tn = "tn" . md5($newfile);
$handle->file_new_name_body = "$newfile_tn";
$handle->Process("images/v");
$thumbnail = $handle->file_dst_name;
// done creating a thumbnail
//$handle-> Clean();
// lets begin with the image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_ratio_no_zoom_in = true;
// is our image too large? Lets resize
if($handle->image_src_x >= 604){
$handle->image_x = 604;
}
if($handle->image_src_y >= 453){
$handle->image_y = 453;
}
// end changes
$handle->file_new_name_body = "$newfile_p";
$handle->Process("images/v");
$handle->Clean();
}
This code worked when I called it with a regular form, however, I have only been able to get it to either create the thumbnail or just upload the image (and if its too big, it won't resize).
I tried using Clean() in there too, that didn't seem to help much. Here is the current code that will just produce two files of the original uploaded image (no resized thumbnail and no resized image)