Process() cutting out.

See all posts Reply

Process() cutting out. new!
by Joseph, 15 years, 8 months ago
I am experiencing some weird effects. Sometimes the class executes properly and other times it returns errors.

This is the code that I am using...
$handle = new upload($_FILES['shirt_front']);
if ($handle->uploaded) {
  $handle->file_new_name_body = $name;
  $handle->image_x = 720;
  $handle->image_y = 720;
  $handle->image_resize = true;
  $handle->allowed = array('image/*');
  $handle->image_convert = 'jpg';
  $handle->file_max_size = 1024 * 300;
  $handle->process(DIR_WS_IMAGES . 'shirtPix/');
  if ($handle->processed) {
    $handle->clean();
    return 'success';
  } else {
    return $handle->error;
  }
}
Sometimes it goes through properly and other times it stops. It has worked for a jpg and a gif, and then I try to send a different jpg and it gets stopped.

I know it is the line of code that calls the process method because I put an echo before and after and it only said the first one.

I looked in the php error log and it didn't even throw an error there. So now I am lost as to what is happening.Reply
Re: Process() cutting out. new!
by colin, 15 years, 8 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", "40M")

Or in a .htaccess file:
php_value memory_limit 40M

If the above doesn't work, ask your hosting company.Reply
Re: Process() cutting out. new!
by Joseph, 15 years, 8 months ago
I am currently running this on my own server so I can change the memory limit.

When I transfer this over to a shared hosting, I might not be able to change it.

If the hosting doesn't allow the additional memory, is there any way to exit the script without a fatal error.

Where I am using this code, it is necessary to be able to exit in a normal fashion in the case of an error.

Thanks for your helpReply
Re: Process() cutting out. new!
by colin, 15 years, 8 months ago
I don't think you can catch this error, as it is a fatal error. Moreover, if you are running out of memory, PHP will not have any more memory to use to actually deal with the error with an error handler. See here.Reply