I make a php script that receive from POST 4 image, than store them and create the thumbs trought GD php library. The problem is that it works only if i load 2 photos 4mb each (or 4 photos 2 mb each, or less; in fact max 8 mb). why? i check the value of memory_limit (64mb), upload_max_filesize (25mb) and max_file_uploads (120secs), and if i increase them, nothing happen.
It seems that POST array is totally ignored : i see this because i put some "echo" on php script. The code is above :
if(($_FILES['userfile1']['tmp_name']!="") or ($_FILES['userfile2']['tmp_name']!="") or ($_FILES['userfile3']['tmp_name']!="") or ($_FILES['userfile4']['tmp_name']!="")) {
// JPG/JPEG, max 4mb each
for($i=1; $i<=4; $i++) {
if ($_FILES['userfile'.$i]['tmp_name']!="") {
$path_parts=pathinfo($_FILES['userfile'.$i]['name']);
if(((strtolower($path_parts['extension'])=='jpg') or (strtolower($path_parts['extension'])=='jpeg'))
&& ($_FILES['userfile'.$i]['size']<=4194304)) {
} else {
$wrong=1;
}
}
}
if(isset($wrong)) {
$abort=1;
$messaggio="Errore - Formato delle foto non valido. Assicurati che il formato sia jpg/jpeg e che la foto non superi i 3 Megabyte";
} else {
mkdir("./articles/photos/".$articleid);
mkdir("./articles/photos/thumbs/".$articleid);
$sql="";
for($i=1; $i<=4; $i++) {
if ($_FILES['userfile'.$i]['tmp_name']!="") {
$photoid=$articleid."-".$i;
$uploaddir="./articles/photos/".$articleid."/";
$userfile_tmp=$_FILES['userfile'.$i]['tmp_name'];
$userfile_name=$_FILES['userfile'.$i]['name'];
$userfile_name=$photoid."@".trim(str_replace(" ", "", $_FILES['userfile'.$i]['name']));
$path_parts=pathinfo($_FILES['userfile'.$i]['name']);
$photoondb=$photoid.".".strtolower($path_parts['extension']);
move_uploaded_file($userfile_tmp, $uploaddir.$photoondb);
// thumbs
$name_new_image="./articles/photos/thumbs/".$articleid."/".$photoondb;
$file = "./articles/photos/".$articleid."/".$photoondb;
list($actualw, $actualh, $type, $attr) = getimagesize($file);
if(($actualw>100) or ($actualh>100)) {
if($actualw>$actualh) {
$v1=$actualw/100;
$width=$actualw/$v1;
$height=$actualh/$v1;
} else {
$v1=$actualh/100;
$width=$actualw/$v1;
$height=$actualh/$v1;
}
}
$qualita=70;
$new_image=imagecreatetruecolor($width, $height);
$src_image=imagecreatefromjpeg($file);
imagecopyresampled($new_image, $src_image, 0, 0, 0, 0, $width, $height, imagesx($src_image), imagesy($src_image));
imagejpeg($new_image, $name_new_image, $qualita);
imagedestroy($new_image);
imagedestroy($src_image);
if($sql!="") $sql.=", ";
$sql.="('$articleid', '$photoondb')";
}
}
}
}
I hope you can understand what i mean, more or less :)