Uploading problems

See all posts Reply

Uploading problems new!
by Richard, 17 years, 3 months ago
When I try to upload a .jpg file that is more than 1 Mb it does not upload ($foo->uploaded is not true) and the log gives me this:

source is an uploaded file
- source variables
    file_src_name : 
    file_src_name_body : 
    file_src_name_ext : 
    file_src_pathname : 
    file_src_mime : 
    file_src_size : (max= 20971520)
    file_src_error : 2

It works fine with files under 1 Mb. What is file_src_error 2? If I resize the image to be less than 1 Mb raw file size, it works ok.Reply
Re: Uploading problems new!
by colin, 17 years, 3 months ago
I don't know the code of your form, but error 2 means:
File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form)

Otherwise, try to raise your memory limit and file upload limit in php.iniReply
Re: Uploading problems new!
by Richard, 17 years, 3 months ago
Thanks for your attention...

The code is below. I notice that the $_FILES['binFile'][size] always returns 0 on files larger than about 750 to 800 Kb. but it is correct on files smaller.

The php.ini settings are
max_execution_time = 60
memory_limit = 32M
post_max_size = 16M
upload_max_filesize = 4M

My code:
$upload = new upload($_FILES['binFile']);
$upload->file_max_size = 4096;
if ($upload->uploaded) {
  $upload->allowed = array('image/jpeg','image/pjpeg','image/jpg','image/gif','image/png');
  $upload->image_convert        = 'jpg';
  $upload->file_new_name_body = $record;
  $upload->image_resize         = true;
  $upload->image_x              = $full_width;
  $upload->image_ratio_y        = true;
  $upload->process($img_basedir.'/full/');
  if ($upload->processed) {
    echo 'Full Image Resized';
    $success = 1;
  } else {
    echo 'Error : ' . $upload->error;
  }
  echo $upload->log;
}

Regards!Reply
Re: Uploading problems new!
by colin, 17 years, 3 months ago
I notice that the $_FILES['binFile'][size] always returns 0 on files larger than about 750 to 800 Kb. but it is correct on files smaller.

That leads me to think that there is a problem with your setup of PHP. The class only reads what is in $_FILES. If the information is not correct, it will assume that the upload is not good. In fact, if the size value is 0, it means that the upload wasn't successful, for some reason.

Does your code work on another server?Reply
Re: Uploading problems new!
by Richard, 17 years, 3 months ago
Thank you for your help. It was occuring on three servers. It was NOT the fault of the class, it was a form problem. We had never had to upload such large files before, so our old class was fine until now.

We replaced it with this one... but the problem was that we were not specifying MAX_FILE_SIZE as hidden input in the upload form...

We added the following hidden input line to the form and eliminated the problems!


It seems like this is required whatever your php.ini says, otherwise the $_FILES array is empty for larger files that the default except for the file name.

Great piece of work you have done here.

Regards!Reply