#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    3
    Rep Power
    0

    Error with ftp_put


    This code was working 2 days ago. this script takes an image resizes and makes thumbnails, then ftps the files to a server!
    It connects, starts the file upload, but dies. leaving one 0byte file. then i get this error

    Warning: ftp_put: PORT command successful. in c:\apache\htdocs\gd\upload.php on line 45

    Fatal error: Maximum execution time of 30 seconds exceeded in c:\apache\htdocs\gd\upload.php on line 46

    ////////////////////////////////////////////////////////////////////////////////////

    PHP Code:
    <?
    $upload_amount
    ='4';
    switch(
    $action_id){
    case 
    3:
    //          Connect to FTP Server!!!!!
            
    $ftp_server "***********";
              
    $conn_id ftp_connect("$ftp_server");
            
    $VIN='test';
              
    $login_result ftp_login($conn_id"*******""*******");
    //        Error Checking the connection
              
    if ((!$conn_id) || (!$login_result)) {
            echo 
    "Ftp connection has failed!<br>";
            echo 
    "Attempted to connect to ".$ftp_server." for user ".$user."<br>";
            die;
              } else {
    //        Begin image resize code!
            
    for($i=0;$i<$upload_amount;$i++){
                  if (
    is_uploaded_file($autoImage[$i])) {
                    
    $image_size[$i] = GetImageSize($autoImage[$i]);
    //        Getting size ratio for larger images with a set width of 500 pixels
                    
    $new_w[$i] = '500';
                    
    $ratio_div1[$i] = $image_size[$i][0] / $new_w[$i];
                    
    $new_h[$i] = $image_size[$i][1] / $ratio_div1[$i];
    //        Rendering Larger Images
                    
    $dst_img[$i] = ImageCreate($new_w[$i],$new_h[$i]);
                    
    $src_img[$i] = ImageCreateFromjpeg($autoImage[$i]);
                    
    ImageCopyResized($dst_img[$i],$src_img[$i],0,0,0,0,$new_w[$i],$new_h[$i],ImageSX($src_img[$i]),ImageSY($src_img[$i]));
                    
    $new_img[$i] = Imagejpeg($dst_img[$i],$autoImage_name[$i],80);
    //      Getting size ratio for thumbnails with a set width of 100 pixels
                    
    $th_w[$i] = '100';
                    
    $ratio_div2[$i] = $image_size[$i][0] / $th_w[$i];
                    
    $th_h[$i] = $image_size[$i][1] / $ratio_div2[$i]; 
    //        Rendering thumbnails
                    
    $dst_th_img[$i] = ImageCreate($th_w[$i],$th_h[$i]);
                    
    $src_th_img[$i] = ImageCreateFromjpeg($autoImage[$i]);
                    
    ImageCopyResized($dst_th_img[$i],$src_th_img[$i],0,0,0,0,$th_w[$i],$th_h[$i],ImageSX($src_th_img[$i]),ImageSY($src_th_img[$i]));
                    
    $th_name[$i] = "th_".$autoImage_name[$i];
                    
    $new_th_img[$i] = Imagejpeg($dst_th_img[$i],$th_name[$i],40);
    //      Upload Now
                    
    if(!$new_img[$i]){echo"<center><b>Upload Failed!</b></center>";
                    }else{
                    
    ftp_chdir($conn_id"htdocs/carlot");
                    
    ftp_mkdir($conn_id$VIN);
                       
    ftp_chdir($conn_id$VIN);
    //        FTP UPLOAD HAPPENS HERE
                    
    ftp_put($conn_id$autoImage_name[$i], $autoImage_name[$i], FTP_BINARY);
                    
    ftp_put($conn_id$th_name[$i], $th_name[$i], FTP_BINARY);
                    
    ImageDestroy($src_img[$i]);
                    
    ImageDestroy($new_th_img[$i]);                
                    }
                }
                }
        }
    break;
    DEFAULT:
    ?>
        <form method='post' enctype='multipart/form-data' action='<?php echo $PHP_SELF."?action_id=3"?>'><input type='hidden' name='VIN' value='<? echo $VIN;?>'><?
        
    for($i=0;$i<$upload_amount;$i++){
        
    $m $i 1;
        echo
    "<b>Photo ".$m."</b><br>
         <input type='file' name='autoImage[]'><br>"
    ;
        }
    ?>
        <input type='submit' name='upload' value='Upload Now'></form>
    <?
    break;
    }
    ?>
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Eh... off hand I'd say it might have something to do with PASV mode. If it's set one way on the server and a different way on the client, connects work fine but any sort of transfer times out. Did the server config get changed recently?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    3
    Rep Power
    0

    Talking I GOT IT!!


    I had to make sure I had the ftp modules installed for the ipchains or iptables. My computer connects to the net through a transparent proxy on another machine, the firewall worked for everything just fine except ftping with my script, which made this hard to find. Once i had the ftp modules installed right, my scripts started working again. Hope this helps those who had the same problem!!!




    Never give up, answers are ment to be found!

IMN logo majestic logo threadwatch logo seochat tools logo