Upload photos -- keeps not responding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brentw505
Forum Newbie
Posts: 2
Joined: Thu Aug 07, 2008 8:09 pm

Upload photos -- keeps not responding

Post by brentw505 »

OK, I'm making a page that you upload photos and then it resizes them and sticks them on the server. The code works half the time. When it doesn't work it just sits there as if it's still loading, but will never stop.

Here's the code

Code: Select all

<?
 
$uploadd = $HTTP_POST_VARS['uploadd'];
 
echo "up: $uploadd :";
 
 
  $uploaddir = '../../images/trucks/';
  $num = (rand()%10000);
  $imageName=$num . $_FILES['attachment']['name'];
  $uploadfile = $uploaddir . $imageName;
 
echo "trying, $uploadfile <br>";
 
 
    if (move_uploaded_file($_FILES['attachment']['tmp_name'], $uploadfile)) {
echo "it's moved..";
    ///resize image
    // Get new sizes
    list($width, $height) = getimagesize($uploadfile);
    $newwidth = 500;
    $newheight = $height * ($newwidth/$width);  
    // Load
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $source = imagecreatefromjpeg($uploadfile); 
    // Resize
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);  
    // Output
    imagejpeg($thumb, $uploadfile);
 
 
 
      echo "MOVED FIRST";
      $img_size = GetImageSize($uploadfile); 
      $Width = $img_size[0];
      $Height = $img_size[1];
      echo "Check server for photo!!";
    $images=$images.$imageName."`";
   }
 
$i=0;
$keepgoing=true;
 
while($keepgoing){
  $i++;
 
  $fl="attachment$i";
echo ":: $fl";
  if($_FILES["$fl"]){
    echo "NEW FILE";
    $num = (rand()%10000);
  $imageName=$num . $_FILES["$fl"]['name'];
  $uploadfile = $uploaddir . $imageName;
//$uploadfile = $uploaddir . $num . $_FILES["$fl"]['name'];
 
      if (move_uploaded_file($_FILES["$fl"]['tmp_name'], $uploadfile)) {
 
        $img_size = GetImageSize($uploadfile); 
        $Width = $img_size[0];
        $Height = $img_size[1];
        $images=$images.$imageName."`";
      }
echo "images:$images";
  }else{
    $keepgoing=false;
    return;
  }
}
 
?>
I did make a php.ini file with: ini_set("upload_max_filesize", "2000000000");
Also, it seems to always work on firefox, but working half the time in Safari.
=/

Any ideas?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Upload photos -- keeps not responding

Post by Christopher »

Check the max file size setting for PHP. You can use phpinfo();
(#10850)
brentw505
Forum Newbie
Posts: 2
Joined: Thu Aug 07, 2008 8:09 pm

Re: Upload photos -- keeps not responding

Post by brentw505 »

Hmm, yeah looks like

upload_max_filesize=2M

and

post_max_size=8M

How do I change that? I made a php.ini file in that directory and stuck ini_set("upload_max_filesize", "60000000000"); in there, but didn't change anything apparently.
Post Reply