Page 1 of 1

Upload photos -- keeps not responding

Posted: Thu Aug 07, 2008 8:24 pm
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?

Re: Upload photos -- keeps not responding

Posted: Thu Aug 07, 2008 11:07 pm
by Christopher
Check the max file size setting for PHP. You can use phpinfo();

Re: Upload photos -- keeps not responding

Posted: Fri Aug 08, 2008 3:55 pm
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.