| re: Problem in large size image uploading.
Hi all,
I have find out that when i commented createthumb() function call, the script become able to upload large image size but i am unable identify the wrong syntax. My php code is below
[PHP]
$newImage= $_FILES['newImage']['name'];
$name='img'.$_SESSION['id'].'.jpeg';
$newImageName='images/profile/'.$name;
move_uploaded_file($_FILES["newImage"]["tmp_name"],$newImageName);
$newwidth=110;
$newheight=110;
createthumb($newImageNameBig,$newImageName,$newwid th,$newheight );
function createthumb($filename,$target,$newwidth,$newheight )
{
// Get new sizes
list($width, $height) = getimagesize($filename);
// Get Proportional Dimensions
if ($width > $height) {
$thumb_w=$newwidth;
$thumb_h=$height*($newheight/$width);
}
if ($width < $height) {
$thumb_w=$width*($newwidth/$height);
$thumb_h=$newheight;
}
if ($width == $height) {
$thumb_w=$newwidth;
$thumb_h=$newheight;
}
// Center Image
$x = ( $newwidth - $thumb_w ) / 2;
$y = ( $newheight - $thumb_h ) / 2;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Change Background
$white = imagecolorallocate($thumb, 255, 255, 255);
imagefill($thumb, 0, 0, $white);
// Resize
imagecopyresized($thumb, $source, $x, $y, 0, 0, $thumb_w, $thumb_h, $width, $height);
//imagecopyresampled($thumb, $source, $x, $y, 0, 0, $thumb_w, $thumb_h, $width, $height);
// Output
imagejpeg($thumb, $target);
// Free Memory
imagedestroy($thumb);
imagedestroy($source);
}
[/PHP]
|