Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ftp_get(3) [php man page]

FTP_GET(3)								 1								FTP_GET(3)

ftp_get - Downloads a file from the FTP server

SYNOPSIS
bool ftp_get (resource $ftp_stream, string $local_file, string $remote_file, int $mode, [int $resumepos]) DESCRIPTION
ftp_get(3) retrieves a remote file from the FTP server, and saves it into a local file. PARAMETERS
o $ftp_stream - The link identifier of the FTP connection. o $local_file - The local file path (will be overwritten if the file already exists). o $remote_file - The remote file path. o $mode - The transfer mode. Must be either FTP_ASCII or FTP_BINARY. o $resumepos - The position in the remote file to start downloading from. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 ftp_get(3) example <?php // define some variables $local_file = 'local.zip'; $server_file = 'server.zip'; // set up basic connection $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 "; } else { echo "There was a problem "; } // close the connection ftp_close($conn_id); ?> SEE ALSO
ftp_pasv(3), ftp_fget(3), ftp_nb_get(3), ftp_nb_fget(3). PHP Documentation Group FTP_GET(3)

Check Out this Related Man Page

FTP_PASV(3)								 1							       FTP_PASV(3)

ftp_pasv - Turns passive mode on or off

SYNOPSIS
bool ftp_pasv (resource $ftp_stream, bool $pasv) DESCRIPTION
ftp_pasv(3) turns on or off passive mode. In passive mode, data connections are initiated by the client, rather than by the server. It may be needed if the client is behind firewall. Please note that ftp_pasv(3) can only be called after a successfull login or otherwise it will fail. PARAMETERS
o $ftp_stream - The link identifier of the FTP connection. o $pasv - If TRUE, the passive mode is turned on, else it's turned off. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 ftp_pasv(3) example <?php $file = 'somefile.txt'; $remote_file = 'readme.txt'; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // turn passive mode on ftp_pasv($conn_id, true); // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file "; } else { echo "There was a problem while uploading $file "; } // close the connection ftp_close($conn_id); ?> PHP Documentation Group FTP_PASV(3)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

executing a remote location script from local server

hi i am having two servers one is local and remote(FTP)server.from local server i have to connect to remote server and execute a shell script i want to run a shell script(remote location) from my local server i am having some knowledge on ftp but i am not getting the result .please give ... (2 Replies)
Discussion started by: srivsn
2 Replies

2. UNIX for Dummies Questions & Answers

Get the most recent file from a remote server

Hi, This is an FTP related query.I hvae 2 files in a remote server with the timestamp attached to it. FilenameYYYYMMDDHHMMSS.EXT. I need to extract both the fileswith the most recent timestamp using the FTP script I have used : ftp Servername blah blah.... MOST_RECENT_FILE1=`ls -1t... (5 Replies)
Discussion started by: anujairaj
5 Replies

3. Shell Programming and Scripting

FTP multiple files from remote server to local server

Hi, I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is... (2 Replies)
Discussion started by: berlin_germany
2 Replies

4. Shell Programming and Scripting

Mailing the output which is there in remote server

Hi all, I have a script which logs in to the remote server with FTP and with the user id/password and list the files in the path of remote server where thefiles resid.i need to email this output(i.e wether the files are present on not under the path) to my email id. Can u please let me know as... (2 Replies)
Discussion started by: OSD
2 Replies

5. UNIX for Dummies Questions & Answers

Mailing the output which is there in remote server

Hi all, I have a script which logs in to the remote server with FTP and with the user id/password and list the files in the path of remote server where thefiles resid.i need to email this output(i.e wether the files are present on not under the path) to my email id. Can u please let me know as... (2 Replies)
Discussion started by: OSD
2 Replies

6. Shell Programming and Scripting

changing permission using FTP

Dear all, i want to change file permision of remote dir using FTP. is that possible? what i'm doing is i'm simply doing chmod 777 filename after establishing the connection with remote server using ftp... but the result showing is 550 SITE CHMOD command failed. can any body plz help?... (3 Replies)
Discussion started by: panknil
3 Replies

7. Solaris

FTP problem

Hi Guys, Got problem when I tried to get files from Solaris server to my PC. The connection transfer was using FTP and the connection was made from the solaris server to my PC. Here's what happened when the file transfer being made: # ftp 10.192.23.230 Connected to 10.192.23.230. 220... (9 Replies)
Discussion started by: raskita
9 Replies

8. Linux

GUI remote connection

Hello, I need a tool for remote GUI connection to Linux machine ,something like remote Desktop in windows?????any help Thanks in advance (4 Replies)
Discussion started by: mm00123
4 Replies

9. Shell Programming and Scripting

Need a FTP help

Hi, After connecting to the remote server by using FTP i need to know the file name residing on the remote path....So that that file name i can pass as a parameter to the main program...FTP program will get called from the main program.... Please let me know the solution. (4 Replies)
Discussion started by: Sagarddd
4 Replies

10. Shell Programming and Scripting

change the mode of the file after FTP

Hi I am FTPing a file to a remote server from my local server. But after I FTP it the permissions are not in executable option, I need to change the permissions of the FTPed file how can i do that. Below is my script LOCALDIR=/batch/ediprocess LOCAL_BACKUP_DIR/batch/ediprocessBackUp... (4 Replies)
Discussion started by: shanth_chandra
4 Replies

11. Shell Programming and Scripting

to check if a remote server is up

I need to check if a remote server is up before i send a file to it through FTP. I thought of using "ping" command to check it. But the problem is, my script needs to run from 2 different servers, one is Solaris and other is HP-UX. And ping works in different way in each of them when I do -... (3 Replies)
Discussion started by: Vidhyaprakash
3 Replies

12. Shell Programming and Scripting

Junk character appearing after downloading the file from windows server

Hello, Im downloading the file from windows server through FTP, the downloaded file is containing some junk character at very start of the file as below and causing my whole script is to fail, how to download without junk or how to remove these before processing it? ▒▒"nmdbfnmdsfsdf" ... (19 Replies)
Discussion started by: Riverstone
19 Replies

13. Ubuntu

Bash script for FTP download -Mysql

Hi guys, I recently managed to write up my working script, but now I have a problem. If the file isn't there in the remote server, my actual script jumps it and all ok, but I need something like this: Search file -> if there, then download -> if not, download next file in the list. Any... (7 Replies)
Discussion started by: virtus96
7 Replies

14. Programming

QFTP connection refused problem in WEC7

Hi I tried FTP transfer from WEC7(Windows Embedded Compact 7) to another windows 7.I am getting the connection refused error. Could you please help me to resolve this. what are the reasons one person can get connection refused while trying to connect through QFTP. Tool : Qt 4.8 Thank... (4 Replies)
Discussion started by: SA_Palani
4 Replies

15. Shell Programming and Scripting

How to check if downloading of a file is completed?

Hello All. We are getting one zip file from another server daily. The size of the zip file will be around 4.5 gb that takes time to download completely. I have to process that file furthest once get downloaded completely. I have written one code for that, but i need suggestion whether it is a... (7 Replies)
Discussion started by: looney
7 Replies