I'm writing a class that will show a list of files and retrieve / send files. I have problem with downloading. I can connect with server, showing list files, but I can't download file.
Warning: ftp_get(index.php): failed to open stream: Permission denied in /var/www/public_html/class.ftp.php on line 51
Warning: ftp_get(): Error opening index.php in /var/www/public_html/class.ftp.php on line 51
When I use application in my PC and this account ftp, I don't have problem with downloading. In principle, I cannot change file permissions, because I will be used multiple ftp. I don't understand, why I don't need change a permission file when I download file with application and PHP needs this permission have.
Code:
protected function connect()
{
$this->connect=ftp_connect($this->host);
$result=ftp_login($this->connect, $this->login, $this->pass);
if($result){
ftp_pasv($this->connect, true);
$this->status=true;
}
else $this->status=false;
}
public function download_file($path)
{
$e=explode('/', $path);
$last=count($e)-1;
$file=$e[$last];
$file='download/'.$file;
return ftp_get($this->connect, $path, $file, FTP_ASCII); //I tried FTP_BINARY
}
Use:
var_dump($conn->download_file('index.php'));
See:
bool(false)
And of course errors.