By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

Problem in large size image uploading.

kamill
P: 71
Dear All,
I am uploading a image file and after resize the image i am saving it. My script is working fine with small size images but when i am trying to upload big size image, i am getting below error.
Error 500 - Internal server error
An internal server error has occured!
Please try again later.

My ini settings are as below

  • file_uploads: On
  • upload_max_filesize: 20M
  • max_input_time: -1
  • memory_limit: 40M
  • max_execution_time: 50000
  • post_max_size: 8M
System Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux
PHP Version 4.4.8

Same code is working on local server.

Please help me to overcome from this frustrating issue.

Regards,
Kamill
Jun 23 '08 #1
Share this Question
Share on Google+
2 Replies


kamill
P: 71
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]
Jun 23 '08 #2

Atli
Expert 5K+
P: 5,058
I don't think this is a problem with your code, but rather with your server.

You say this is working on your local server, but not you host.
What are the differences between the two?
Are they running the same PHP version with the same settings?

Is it possible that your host is limiting the resources you can use in such a way that it would cut off your script when it is using to much RAM or CPU?
Jun 23 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.