473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ftp_get: what goes wrong?

4 New Member
Hi all,

I am trying to download files from a remote with the use of ftp_get.
Somehow, the script always return to false.

Here's what I got:

[php]
$conn_id = ftp_connect($ft p_host);
$login_result = ftp_login($conn _id, $ftp_username, $ftp_password);

if ((!$conn_id) || (!$login_result )){
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_host for user $ftp_username";
exit;
} else {
echo "Connected to $ftp_host, for user $ftp_username";

//change directory
$ftp_chdir = ftp_chdir($conn _id,$remote_pat h);
//retrieves files in the directory
$file_slist = ftp_nlist($conn _id,$remote_pat h);
//open local directory
$dir_opn = opendir($local_ path);

//get all the remote files
foreach ($file_slist as $file_s) {
$ftp_get = ftp_get($conn_i d,$local_path.$ local_file,$rem ote_path.$file_ s,FTP_ASCII);
}

//close dir
closedir($ftp_c hdir);

//close ftp connection
ftp_close($conn _id);

} //else
[/php]

Do I set the right parameters?


Thanks in advice!
Jan 23 '07 #1
2 1706
ronverdonk
4,258 Recognized Expert Specialist
It looks okay, as long as you are really sure that all the other steps were completed correctly. Therefore myou should test the result of each function performed.
Since ftp_chdir() is supposed to throw its own php error in case of failure, I advise you to test the results of your commands, because there could be the root of the problem. Adapt the following commands by capturing any possible errors:

[php]if (!$ftp_slist)
die ("ftp_nlist failed");

if (!$dir_opn)
die ("open_dir failed");[/php]
Ronald :cool:
Jan 23 '07 #2
cxian
4 New Member
Okay, there should be some error there.

Thank you very much.
Jan 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1958
by: John | last post by:
Are there any precautions that I should take when downloading a file from a remote file on Linux platform to a local file in Win98 platform? I am using the method ftp_get $remotefile = '../products.txt'; $localfile = 'C:/data/products.txt'; ftp_get($conn, $localfile, $remotefile, FTP_ASCII)) Thank you John
0
1677
by: rstuckart | last post by:
A script successfully connects to a remote server, logs in, reports the size of a file on the server. The problem is that it will not download the file with either ftp_get or ftp_fget. The Configure Command shows: --enable-safe-mode, but safe_mode is OFF, safe_mode_exec_dir has no value, safe_mode_gid is ON, safe_mode_include_dir and open_basedir each have no value. Function set_time_limit() runs without complaint, so I am fairly...
1
1969
by: ralphNOSPAM | last post by:
I'm trying to download a text file named KLAX.TXT at tgftp.nws.noaa.gov using if (ftp_get($conn_id, "Metar Reports/$local_file", $server_file, FTP_BINARY)) { print "Success";
1
1392
by: Klaasjan | last post by:
Hi, In my programm users can enter text which is added to a richtextbox. Everytime a text is added, this text had get his own color. The first 2 times it goes fine, eg. hallo (red) hallo (yellow)
5
5521
by: Alex | last post by:
I'm trying to make simple ftp client, used the following article for base: http://www.devarticles.com/c/a/PHP/Building-An-FTP-Client-With-PHP/3/ All works, I can login, see list of files, but except ftp_put and ftp_get functions. They return always false. I tried to set passive mode, it doesn't help. Any advice will be appreciated.
1
1771
by: irfan.mohammed | last post by:
Dear All, I need your help,i am using ftp_get for getting the file from remote machine.now i am able to save only at one location.i want the user to select the directory any where in the computer and able to save it. Thanks in advance Irfan
13
4405
unicorn
by: unicorn | last post by:
Hi guys, I have moved my site from one domain to another. it worked perfectly on old domain, ftp_put(), ftp_delete() - i.e. FTP upload and remove scripts work fine, but... i have problem using ftp_get() wicth shows me error, and says : Warning: ftp_get() : Error opening 4.gif in /home/mydomain/public_html/down_att.php on line 43 Couldn't download file '4.gif' . i have checked connection, path. well if i change path (ftp...
2
4980
by: empiresolutions | last post by:
I am using ftp_get to transfer a file from a secure location, to a temp location. (working) Once at the temp location i need to have the file automatically download to the clients local machine. Something like a right click "save as" action. How do i do this? I'm thinking its done with headers but not sure. My Current Code is below. Thanks for all responses. // define some variables $ftp_server = "123.45.67.890"; $local_file =...
1
1645
by: marcarlem | last post by:
Sorry about my english but it´s not my first lenaguage. i got a problem using ftp_get. My FTP server is working properly (I can upload and download files to it) but when I try to download a File using PHP code doesn´t seems work. The file is saved in the ServerSide instead clientSide. this is a portion of my code. $Local and $Remoto has the same name of file, without path, but don´t work wether add a path or not to $Local I would appreciate...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.