Problem in large size image uploading.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kamill
    New Member
    • Dec 2006
    • 71

    Problem in large size image uploading.

    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_file size: 20M
    • max_input_time: -1
    • memory_limit: 40M
    • max_execution_t ime: 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
  • kamill
    New Member
    • Dec 2006
    • 71

    #2
    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'.$_S ESSION['id'].'.jpeg';
    $newImageName=' images/profile/'.$name;
    move_uploaded_f ile($_FILES["newImage"]["tmp_name"],$newImageName) ;

    $newwidth=110;
    $newheight=110;
    createthumb($ne wImageNameBig,$ newImageName,$n ewwidth,$newhei ght );

    function createthumb($fi lename,$target, $newwidth,$newh eight )
    {
    // Get new sizes
    list($width, $height) = getimagesize($f ilename);

    // Get Proportional Dimensions
    if ($width > $height) {
    $thumb_w=$newwi dth;
    $thumb_h=$heigh t*($newheight/$width);
    }
    if ($width < $height) {
    $thumb_w=$width *($newwidth/$height);
    $thumb_h=$newhe ight;
    }
    if ($width == $height) {
    $thumb_w=$newwi dth;
    $thumb_h=$newhe ight;
    }

    // Center Image
    $x = ( $newwidth - $thumb_w ) / 2;
    $y = ( $newheight - $thumb_h ) / 2;

    // Load
    $thumb = imagecreatetrue color($newwidth , $newheight);
    $source = imagecreatefrom jpeg($filename) ;

    // Change Background
    $white = imagecoloralloc ate($thumb, 255, 255, 255);
    imagefill($thum b, 0, 0, $white);

    // Resize
    imagecopyresize d($thumb, $source, $x, $y, 0, 0, $thumb_w, $thumb_h, $width, $height);
    //imagecopyresamp led($thumb, $source, $x, $y, 0, 0, $thumb_w, $thumb_h, $width, $height);
    // Output
    imagejpeg($thum b, $target);
    // Free Memory
    imagedestroy($t humb);
    imagedestroy($s ource);
    }

    [/PHP]

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      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?

      Comment

      Working...