This is an interesting problem. I need to connect to ftp server via our proxy server.
i've tried to use fopen() and fsockopen() but this had no result.
Anybody know the solution?
FTP via PROXY!
Use PHP's FTP functions.
sven@cartell-network.de
13-Feb-2002 11:27
connection to a ftp server across proxy
$ftp_server = "proxy"; f.e. 123.456.789.10
$ftp_user_name = "username@ftpserver"; f.e.
exampleuk@www.example.uk
$ftp_user_pass = "password";
$conn_id = ftp_connect($ftp_server, 2121);
$login_result = ftp_login( $conn_id, $ftp_user_name, $ftp_user_pass );
This answer is really useful. The other useful function is set_time_limit(0);
Thanks, David
follow-up question , how do I download the files?
after connecting to the ftp server that is behind proxy the following commands does not work
$conn_id = ftp_connect("ftp_proxy",2121) or die('Could not connect to FTP-server.');
if(ftp_login($conn_id, "ftp_username@ftp_server", "ftp_password")) {
echo 'Connected to FTP-server.';
ftp_chdir($conn_id, "History");//( ! ) Warning: ftp_chdir(): CWD failed. "/History": directory not found.
$server_file = "2019-02.mdb";
$local_file ="2019-02.mdb";
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { // Warning: ftp_get(): File not found
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
}
- Edited
There is no folder called "/History" on the server. Give it the correct path, it should help.
You might trying giving ftp_chdir() the full path as a parameter ... perhaps you're not in the directory you think you're in?
[upl-image-preview url=https://board.phpbuilder.com/assets/files/2019-02-07/1549563787-632667-screen-shot-2019-02-07-at-12259-pm.png]
That may be a record for old thread resurrection.
I'm sorry, if there is an answer pls redirect me to the page, I really need my project get goiing
Thank you very much for the reply, yes you are correct. Looks like I over exhaust myself that I already did not noticed
For that to be interesting, the solution was simple.
The contents of the text file containing FTP connection information must be replaced by:
open XXX.XXX.XXX.XXX
login @ address_of_ftp
password
XXX.XXX.XXX.XXX is the proxy address
A simple syntax problem ...