I have a persistent volume defined in server under www/public/images/logo/
I want to list all the files inside that folder. So far I have done following lines with no luck.
public function getFiles($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$url = 'https://myurl.de/images/logo/';
$data = $this->getFiles($url);
Can anybody please help ?
Advertisement
Answer
If you are want to list all files on same server then you can use php function scandir();
If you are want to list all files on remote server then you need to connect it using ftp like below code.
$connection = ftp_connect("HOST_NAME");
$login = ftp_login($connection, "FTP_USERNAME","FTP_PASSWORD");
ftp_pasv($connection, true);
$fileList = ftp_nlist($connection,'DIRECTORY_ON_FTP');
ftp_close($connection);