FTP Problem

Discussion in 'PHP' started by onlyican.com, Apr 12, 2006.

  1. #1
    Hey guys

    This is really bugging me

    I have this script to upload

    $file_name = $_FILES["ufile"]["name"]

    $track2 = "mynewname.".$ext;

    // set up basic connection
    $conn_id = ftp_connect("www.?.com");
    
    // login with username and password
    $login_result = ftp_login($conn_id, "?", "?");
    
    // check connection
    if ((!$conn_id) || (!$login_result)) {
           echo "FTP connection has failed!";
           exit;
       } else {
           echo "Connected to FTP";
       }
       
    
      set_time_limit(300);
    	  $ret = ftp_nb_put($conn_id, $track2, $file_name, FTP_BINARY);
    while ($ret == FTP_MOREDATA) {
      
    
       echo "Please wait, your file is uploading.";
    
       // Continue uploading...
       $ret = ftp_nb_continue($conn_id);
    }
    
    if ($ret != FTP_FINISHED) {
       echo "<br><br>There was an error uploading the file...<br><br>";
       exit;
    }else{
    echo "<br><br>Yea, the file have been uploaded<br><br>";
    }
    	  
    // close the FTP stream
    ftp_close($conn_id);
    PHP:
    I am trying to upload a 2.5MB file

    My hosting company changed the MaxUploadSize to 50MB and it works

    But I thought FTP ignores this size and FTP in the form is unlimtied.
    Have I done something wrong
     
    onlyican.com, Apr 12, 2006 IP
  2. Slapyo

    Slapyo Well-Known Member

    Messages:
    266
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    I'm not sure if I understand this correctly. You have a webpage that has a form on it so that people can upload a file through FTP, correct?

    My first guess is that you can't do that through the form. But what you can do is upload the file normally. Once it is uploaded you move it to a temp folder and then you would fire off the FTP part to then take the file and FTP it. But if where you are placing the file is on the same server, then there shouldn't be a need to use FTP ... just the file upload and then moving the temp file to the correct location. Check out the link below.

    http://us3.php.net/manual/en/features.file-upload.php#features.file-upload.post-method
     
    Slapyo, Apr 12, 2006 IP