Reputation: 11250
I'm using class.upload.php to upload images to a page. It seems a script that previously worked is now basically stopping part way through without any errors. At each line in the script, I'm echoing a number so I can get an idea at which point it stops, ie:
// save uploaded image with a new name
$foo->file_new_name_body = $image_name;
$foo->Process($save_directory);
if ($foo->processed) {
echo 'original image copied 1';
} else {
echo 'error 1: ' . $foo->error;
}
echo '1'; $foo->file_new_name_body = $image_name . '_medium';
echo '2'; $foo->image_resize = true;
echo '3'; $foo->image_convert = jpg;
echo '4'; $foo->image_x = 300;
echo '5'; $foo->image_ratio_y = true;
echo '6'; $foo->file_overwrite = true;
echo '7'; $foo->Process($save_directory);
echo '8';
if ($foo->processed) {
echo 'original image copied';
} else {
echo 'error 2: ' . $foo->error;
}
Output:
original image copied 1
1
2
3
4
5
6
7
I have no way to explain it. No errors. No feedback. No further code after echo '7'; is executed. What is going on? How can I debug?
What would be causing this kind of behaviour?
Edit I was able to fix the issue simply by changing the file being uploaded. It was 2000px wide and when I saved it as a smaller 800px image it completed the process.
I changed the memory as suggested to 40m, however this still doesn't let me process a 2000px wide image which doesn't really make much sense to me. How much memory is needed to deal with files these sizes?
Upvotes: 0
Views: 620
Reputation: 3194
Check your memory limit, I find that if I hit that, PHP can (does?) just quit without saying anything.
Upvotes: 2
Reputation: 23916
What is set to in your php.ini - this for example will show almost any error.
error_reporting = E_ALL & ~E_NOTICE
Upvotes: 1
Reputation: 882776
Well, I'm no rocket scientist (a) but it seems to me that the most likely cause is that you're not exiting from the call to $foo->Process($save_directory)
.
You probably need to debug that little beast to find out the reason why.
First step would be to output $save_directory
and $image_name
to see what they contain.
Second, I would comment out all those flag setting statements and see if it works with just the copy. Then add them back in one at a time until it starts failing again.
It may be that there's either a bug in the conversion code or something wrong with the uploaded image file which causes it to hang. If the latter, perhaps another (simpler) image file may work - it's worth checking.
It's no surprise that it would hang at that point, since all the other statement are simply setting up flags for the process
call.
And, as a last resort, you have access to the source. You can simply make your own copy of it (if you don't already have one) and insert debug statements into that to see where it's stopping.
The code for process
is actually quite logically laid out. It appears to be a succession of blocks of the form:
if ($this->processed) {
# Attempt to do next stage, setting
# $this->processed to false if there's a problem.
}
So you could just insert an echo statement before each block to find out which block is causing the problem, then start inserting more debug statements within that block until you narrow it down to the actual line.
You may also want to look at the FAQ, especially the bit that states upping the PHP memory limits may assist with larger images. There is also the forums but I see you've already started to go down that route :-)
(a) : What do rocket scientists say in this situation?
Upvotes: 2