It shows
128M 128M
I am adding the whole script so someone can see if something wrong catches their eye.
error_reporting(E_ALL);
ini_set("display_errors", 1);
echo ini_get("memory_limit");
ini_set("memory_limit","128M");
echo ini_get("memory_limit");
foreach ($_FILES["userfile"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
// Grabs everything before and after the last dot and turn it into the new filename.
$imgfile = $_FILES['userfile']['tmp_name'][$key];
$imgfile_name = $_FILES['userfile']['name'][$key];
$imgfile_size = $_FILES['userfile']['size'][$key];
$imgfile_type = $_FILES['userfile']['type'][$key];
$dir="/home/u1/tomthumb/html/gallery/";
srand((double)microtime()*1000000);
$unique_str = md5(rand(0,9999999));
$p = strrpos($imgfile_name, "." );
$old_name = substr($imgfile_name , 0 , $p ) . $unique_str . substr($imgfile_name , $p , ( strlen($imgfile_name ) - $p ) );
/*== upload directory where the file will be stored
relative to where script is run ==*/
$uploaddir = "/gallery";
/*== get file extension (fn at bottom of script) ==*/
$pext = getFileExtension($imgfile_name);
$pext = strtolower($pext);
//-- RE-SIZING UPLOADED IMAGE
/*== only resize if the image is larger than 50 x 50 ==*/
// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($imgfile);
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($imgfile);
$newwidth=400;
$diff = $width / $newwidth;
//$newheight=($height/$width)*100;
$newheight= $height / $diff;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
// now write the resized image to disk.
/*== setup final file location and name ==*/
/*== change spaces to underscores in filename ==*/
$new_name = str_replace(" ","_",$old_name);
$newfile = $dir . "/$new_name";
if (is_uploaded_file($imgfile))
{
/*== move file to proper directory ==*/
if (!copy($imgfile,$newfile))
{
/*== if an error occurs the file could not
be written, read or possibly does not exist ==*/
print "Error Uploading File.";
exit();
}
}
/*== delete the temporary uploaded file ==*/
imagedestroy($tmp);
imagedestroy($src);
unlink($imgfile);
}
}
/*== FUNCTIONS ==*/
function getFileExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}