need help on php ftp client code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
squirrel
Forum Newbie
Posts: 1
Joined: Tue Aug 25, 2009 10:32 am

need help on php ftp client code

Post by squirrel »

Hi,
I've written a code to download some folders/files via ftp. Whenever i run the code in the hosted server by writing the http://localhost/ftp.php it works fine. But whenever i try to download files/folder from another pc by writing http://10.10.30.34/ftp.php, i see that the download process starts on the server itself... what I want to mean is that, the required file is seen downloaded in the server pc itself, but i want to download it to another pc as i'm running it from another pc.
Please help...
here is my code in simplified form:

<?php
require ("connection.php");
set_time_limit(480);
$conn=ftp_connection();
function file_downloader($conn, $remote_file, $local_file)
{
if (ftp_get($conn, $local_file, $remote_file, FTP_ASCII))
{
echo "<br>Successfully written to $local_file";
}
else
{
echo "There was a problem with the file " . "<br>";
}

}
$local_file=config.bat;
$remote_file=/c/config.bat;

file_downloader($conn, $remote_file, $local_file);
?>
Post Reply