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 have a problem with resizing multiple files, i want to upload multiple files, then resize them, but when i run my code, it crashes on processing image, and there is no error! but i found the problem, the problem is setting for resize and crop, but what could i do for resizing multiple files? this is my code:
if ( isset($_POST['submit']) ) {
$files = array();
foreach ($_FILES['my_field'] as $k => $l) {
foreach ($l as $i => $v) {
if (!array_key_exists($i, $files))
$files[$i] = array();
$files[$i][$k] = $v;
}
}
foreach ($files as $file) {
$handle = new Upload($file);
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->image_x = 100;
$handle->image_y = 200;
$handle->Process('./thumb/');
if ($handle->processed) {
echo('ok');
} else {
echo('Thumb Error!');
}
}
}
}
You need to raise the PHP memory limit, usually in php.ini. On shared hosting, you probably can't edit your php.ini, so you can try the following, although it will work only if the hosting company allows it, which they usually don't.
You can add this in your script:
ini_set ( "memory_limit", "80M")
Or in a .htaccess file:
php_value memory_limit 80M
If the above doesn't work, ask your hosting company.Reply
i have a problem with resizing multiple files, i want to upload multiple files, then resize them, but when i run my code, it crashes on processing image, and there is no error! but i found the problem, the problem is setting for resize and crop, but what could i do for resizing multiple files? this is my code:
Search for memory in the site, or click here.
You can also check this post.
You need to raise the PHP memory limit, usually in php.ini. On shared hosting, you probably can't edit your php.ini, so you can try the following, although it will work only if the hosting company allows it, which they usually don't.
You can add this in your script:
Or in a .htaccess file:
If the above doesn't work, ask your hosting company.