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.
But you code is strange... Why are you using $handle when you instantiated the class with $foo? Also, why are you using mime_fileinfo? You cannot use it like this.Reply
I can run the scrip and it save the image - only it isn't resizing them ;(
This is what I have so far
include('class.upload.php'); $handle->mime_fileinfo = false; $foo = new Upload($_FILES['image']); $handle->mime_fileinfo = false; if ($foo->uploaded) { // save uploaded image with no changes $foo->Process('../images/products/test/'); if ($foo->processed) { echo 'original image copied'; } else { echo 'error : ' . $foo->error; } // save uploaded image with a new name $foo->file_new_name_body = $seo_name; $foo->Process('../images/products/l/'); if ($foo->processed) { echo 'image copied
';
} else {
echo 'error : ' . $foo->error;
}
echo '
';
// save uploaded image with a new name,
// resized to 100px wide
$handle->mime_fileinfo = false;
$foo->file_new_name_body = $seo_name;
$handle->file_overwrite = true;
$foo->image_resize = true;
$foo->image_ratio_fill = 'R';
$$foo->image_ratio_y = true;
$foo->image_x = 295;
$foo->Process('../images/products/m/');
if ($foo->processed) {
echo 'image renamed, resized x=295
';
} else {
echo 'error : ' . $foo->error;
}
echo '
';
// save uploaded image with a new name,
// resized to 100px wide
$handle->mime_fileinfo = false;
$foo->file_new_name_body = $seo_name;
$handle->file_overwrite = true;
$foo->image_resize = true;
$foo->image_ratio_fill = 'R';
$foo->image_y = 145;
$foo->image_x = 115;
$foo->image_convert = 'jpg';
$foo->jpeg_quality = 80;
$foo->Process('../images/products/s/');
if ($foo->processed) {
echo 'image renamed, resized x=115 and y=145
';
$foo->Clean();
} else {
echo 'error : ' . $foo->error;
}
}But you code is strange... Why are you using $handle when you instantiated the class with $foo? Also, why are you using mime_fileinfo? You cannot use it like this.