Jump to content

Retrieving Remote Files


cxian

Recommended Posts

Hi all, I am quite a beginner in PHP and really needed your help guys. It happens that I have a problem with accessing remote files that gets me frustrated for two weeks now.

This site I have running on PHP provide to download video files that is stored in the same server.

Unfortunately, I'm losing space and decided to moved some of the video files to other server. I used [b][i]ftp_connect[/i][/b] function as a connection handle and [b][i]ftp_chdir[/i][/b] going to the archive folder. The actual problem is the method for retrieving/ downloading the files. I can use [b][i]ftp_get[/i][/b] but this is unsuitable for large files. [i](I suppose...)[/i]

[i]Is it possible to use [u]symbolic link[/u] for getting remote files?
What other alternative PHP function I can use for getting remote files?
If there's none, Somebody know third party program I can use here?[/i]

Your kindly responses is deeply appreciated.

[b]Thanks[/b]
Link to comment
https://forums.phpfreaks.com/topic/35603-retrieving-remote-files/
Share on other sites

Thanks for a quick reply. I mean, there's one problem I 'read' in other PHP forum [i](Unfortunately, I forgot the name of the site)[/i], that [b][i]ftp_get[/i][/b] having problems with downloading of large files. Okay, I also like to prove it myself if this the true case. I use in the function in my code but it isn't working, Can you find something wrong with these parameters?

[color=red]$conn_id = ftp_connect($ftp_host);
$login_result = ftp_login($conn_id, $ftp_username, $ftp_password);

if ((!$conn_id) || (!$login_result)){

        echo "FTP connection has failed!";
        exit;

    } else {

        echo "Connected to $ftp_host, for user $ftp_username";

          [color=orange]//change directory[/color]
          $ftp_chdir = ftp_chdir($conn_id,$remote_path);

          [color=orange]//retrieves files in the directory[/color]
          $file_slist = ftp_nlist($conn_id,$remote_path);

          [color=orange]//open local directory[/color]
          $dir_opn = opendir($local_path);

          [color=orange]//get all the remote files[/color]
          foreach ($file_slist as $file_s) {

              $ftp_get = ftp_get($conn_id,$local_path.$local_file,$remote_path.$file_s,FTP_ASCII);

                  }

          [color=orange]//close dir[/color]
          closedir($ftp_chdir);

          [color=orange]//close ftp connection[/color]
        ftp_close($conn_id);


    } //else
} //end[/color]

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.