I am working on an image upload script and ran into this problem. Using ImageMagick I would run out of time resizing and uploading images so I inserted these two lines:
set_time_limit(120);
ini_set('max_input_time', 120);
Now however, the script never ends. It is continually running the page even though it uploads, resizes, and inserts to the database fine. Do these conflict with each other in some way? It even goes past the 120 seconds I set as the time limit.
Edit: This is the full image editing portion of the script, it works with say 1 or 2 images but when I put in more (thereby making it take longer) it does not.
set_time_limit(120);
ini_set('max_input_time', 120);
$resource = NewMagickWand();
MagickReadImage($resource,$image);
MagickSetImageCompressionQuality( $resource, 100);
$resource = MagickTransformImage($resource,'0x0','660x500');
MagickWriteImage($resource, $image);
DestroyMagickWand($resource);
This is the code I use to read all the images that are to be uploaded: (reSizePic is the function that calls the code above)
$numberImages = count($_FILES['galFile']['name'])-1;
for($i=1;$i<=$numberImages;$i++)
{
$imageName = $_FILES['galFile']['name'][$i];
$imageType = $_FILES['galFile']['type'][$i];
$imageSize = $_FILES['galFile']['size'][$i];
$imageTemp = $_FILES['galFile']['tmp_name'][$i];
$imageError = $_FILES['galFile']['error'][$i];
//Make sure it is an image
if(in_array(end(explode(".", $imageName)), $allowed))
{
//Where to upload image to
$uploadFile = $uploadDir . $imageName;
if (file_exists($uploadFile))
{
//What to do if file already exists
//Append random number to the end
$front = explode(".", $imageName);
$randomNum = rand(1,100);
$front[0] = $front[0].$randomNum;
$imageName = $front[0].".".$front[1];
$uploadFile = $uploadDir . $imageName;
}
if(move_uploaded_file($imageTemp,$uploadFile))
{
//Add $imageName to DB
$query = "INSERT INTO galleryImages VALUES(\"0\",\"$lastInsert\",\"$imageName\",\"$i\")";
mysql_query($query);
reSizePic($uploadFile);
}
}
Levi