how to copy files from ftp directory to web-accessible directory?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    how to copy files from ftp directory to web-accessible directory?

    I need to copy files from an ftp directory to a web-accessible directory and
    then delete the files in the ftp directory. (I am doing it this way because
    web-based form upload can not exceed 2MB and I can't change that)

    Any ideas are much appreicated!


  • pangea33

    #2
    Re: how to copy files from ftp directory to web-accessible directory?

    Paul wrote:
    I need to copy files from an ftp directory to a web-accessible directory and
    then delete the files in the ftp directory. (I am doing it this way because
    web-based form upload can not exceed 2MB and I can't change that)
    >
    Any ideas are much appreicated!
    You can put a script like this on your webserver with the correct info,
    then just run it in your browser. It will move the file.

    <?php

    $ftp_server = 'ftp.domain.com ';
    $ftp_user_name = 'ftpuser';
    $ftp_user_pass = 'ftppass';
    $server_file = '/ftppathtofile.e xt';
    $local_file = '/dirpathtofile.e xt';

    $conn_id = ftp_connect($ft p_server);
    $login_result = ftp_login($conn _id, $ftp_user_name, $ftp_user_pass) ;

    if ((!$conn_id) || (!$login_result )) {
    echo "FTP connection has failed.\n";
    echo "Attempted to connect to $ftp_server for user $ftp_user_name. \n";
    exit;
    } else {
    echo "Connected to $ftp_server.\n" ;
    }

    //DOWNLOAD
    $download = ftp_get($conn_i d, $local_file, $server_file, FTP_BINARY);
    if ($download) {
    echo "Successful ly written to $local_file\n";
    } else {
    echo "There was a problem\n";
    }

    ftp_close($conn _id);

    ?>

    Comment

    • Paul

      #3
      Re: how to copy files from ftp directory to web-accessible directory?

      thanks "pangea33" , I'll give it a try.


      Comment

      Working...