Re: ftp_get and file downloads
| From: | John Kaspar | Date: | Mon, 05 May 2003 21:46:04 +0000 |
| Subject: | Re: ftp_get and file downloads | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146459@lists.php.net to get a copy of this message | ||
Then I don't understand the warning message:
Connected to ftp. ... .org, for user ...
Warning: ftp_get(): error opening /home/john/download/test.txt in /home/.../www/code/backup.phtml on line 26
Ftp transfer has failed!
I have tried many variations of $local_file for both my winxp and linux computers. I set the local folder "/home/john/download/" on linux to 777.
--------------------------------------
<?php
$ftp_server = "ftp....org";
$user = "...";
$password = "...";
$conn_id = ftp_connect("$ftp_server");
$login_result = ftp_login($conn_id, "$user", "$password");
if ((!$conn_id) || (!$login_result)) {
echo "Ftp connection has failed!";
echo "Attempted to connect to $ftp_server for user $user";
die;
} else {
echo "Connected to $ftp_server, for user $user";} $local_file = "/home/john/download/test.txt"; $server_file = "/www/test.txt"; $transfer = ftp_get($conn_id, $local_file, $server_file, FTP_ASCII); if (!$transfer) {
echo "Ftp transfer has failed!";} else {
echo "Downloaded $server_file on $ftp_server as $local_file";} ftp_quit($conn_id); ?> Ideas? Thanks. On 5/5/2003 3:55 PM, Tyler Longren wrote:
I don't think local is on A. It's on computer B. local refers to the name you want the remote file to be named on your computer B. Example: you want to transfer foo.txt from A to B. You'd do this: ftp_get($conn, "foo.txt.downloaded", "foo.txt", FTP_ASCII); So, it will download foo.txt and save it to computer B with the "foo.txt.downloaded" filename. Hope that helps, Tyler Longren