tags:

views:

241

answers:

5

Hi

Here is my prob in Brief.

I know how to upload a file to server using FTP with programming language PHP.

But is that possible to get files from another server to our server using PHP with

having the FTP Username and Password

Thanks n advance...

Fero

A: 

Do the servers support FXP? They will need to.

Michael
+2  A: 

Yes, you can fetch files from FTP using PHP - using ftp_get.

The following snippet is from the documentation:

$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
    echo "Successfully written to $local_file\n";
}
else {
    echo "There was a problem\n";
}
Dominic Rodger
A: 

Here's a link to a promising function:

http://www.php.net/manual/en/function.ftp-fget.php

You'll need to open the local file up for dumping into, and manage the connection and whatnot, but this is the way to do it.

Alex Mcp
+2  A: 

Technically, the FTP protocol allows for server-to-server transfers, called FXP. This feature is disabled by default on most FTP servers, though, for security reasons, so you would need to be able to verify/enable it before it would work.

If it is enabled, you should just need to script the FXP commands and everything should work fine.

Guy Starbuck
hi starbuck.. I don't want to use FTP features. i need to use with PHP
Fero
A: 

I don't think it's much different from copying a file from a directory to another, provided that you know how to open a file in an FTP Server..

ercan