PHP FTP_PUT Trouble

Discussion in 'PHP' started by koolsamule, Oct 27, 2010.

  1. #1
    Hi Chaps,

    I've created a web-based FTP site, but having trouble with PHP's FTP_PUT function.

    I've tried:
    // FTP access parameters
    $host = 'ftp.example.org';
    $usr = 'example_user';
    $pwd = 'example_password';
     
    // file to move:
    $local_file = './example.zip';
    $ftp_path = '/data/example.zip';
     
    // connect to FTP server (port 21)
    $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
     
    // send access parameters
    ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
     
    // turn on passive mode transfers (some servers need this)
    // ftp_pasv ($conn_id, true);
     
    // perform file upload
    $upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_BINARY);
     
    // check upload status:
    print (!$upload) ? 'Cannot upload' : 'Upload complete';
    print "\n";
     
    // close the FTP stream
    ftp_close($conn_id);
    PHP:
    And also Net_FTP's FTP_PUT function:
    require_once 'Net/FTP.php';
    
      $test = new Net_FTP('www.domain.co.uk', 21);
      
      $test->connect('www.domain.co.uk', 21);
      
      $test->login('username', 'password');
      
    $file_tmp = $_FILES["file"]["tmp_name"];
    $file_name = $_FILES["file"]["name"];
    
    $test->put($file_tmp, 'Uploads/'.$file_name, FTP_BINARY);
    PHP:
    I've tested this with a very small text file and it works OK, but when I try with a zip file of around 9Mb it takes FOREVER, and sometimes doesn't upload at all, or if it does, it has a size of 0kb.

    I need the script to handle big files up to 150Mb in size.

    What can I do to speed up the process and is there something I have missed (current config settings > ini_set('max_upload_filesize', 150000000)) ?
     
    koolsamule, Oct 27, 2010 IP
  2. fr33lanc3

    fr33lanc3 Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Also modify post_max_size.


    Post max size has to be larger than upload max size. Post max is an accumulation of all files uploaded. So, max upload filesize would be per file, post max size would be for all files processed on the submit.

    You may want to up max_execution_time also if the page is timing out.
     
    fr33lanc3, Oct 29, 2010 IP
  3. koolsamule

    koolsamule Peon

    Messages:
    101
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    cool, thanks for the reply, i'll give it a go on monday
     
    koolsamule, Oct 30, 2010 IP