Problem with resizing multiple files

See all posts Reply

Problem with resizing multiple files new!
by Amin, 15 years, 11 months ago
hi everybody.

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!');
      }
    }
  }
}
Reply
Re: Problem with resizing multiple files new!
by colin, 15 years, 11 months ago
You are running out of memory.

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:
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