0

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);
?> 
Lakshya Raj
  • 1,669
  • 3
  • 10
  • 34
sehp
  • 1
  • You are missing basic principles of web page development. To give you some idea, what does for example the download implementation involve, see [List and download clicked file from FTP](https://stackoverflow.com/q/52855025/850848). For the upload, see [Displaying recently uploaded images from remote ftp server - PHP](https://stackoverflow.com/q/60503236/850848). – Martin Prikryl Feb 12 '21 at 13:24
  • Just saying _"it doesn't work"_ doesn't give us anything to go on (and is kind of assumed since you posted a question here.) Please explain what actually happens. Error messages? Wrong data? What are you expecting to happen? Please also include any debugging you have done. – M. Eriksson Feb 12 '21 at 13:44

0 Answers0