Hello I am trying to make a web user interface for ftp server using PHP scripts. So far I have a connection working fine and also I can login with a user. But when I tried to download or upload a file from my computer with localhost/test.php
page it doesn't work. But it works fine when I tried on the command line.
I have given all the files permissions. And I've checked the php.ini config file too. Also I have this ftp server on the same machine that I am trying to make PHP user interface. Can this be a problem? I am new to using ftp server and not familiar with PHP neither.
<?php
$ftp_server = "10.0.2.5";
$ftp_user = "anonymous";
$ftp_password = "none";
// connect and login to FTP server anonimously
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_user, $ftp_password) or die("Could not login to $ftp_server");
$local_file = "ii.txt";
$server_file = "ex.txt";
// download server file
if (ftp_get($ftp_conn, $local_file, $server_file, FTP_ASCII))
{
echo "Successfully written to $local_file.";
}
else
{
echo "Error downloading $server_file.";
}
ftp_close($ftp_conn);
?>