0

I have png photos uploaded to the ftp server. I want to see these photos directly on my local website. I don't want to download photos to the local. I want to have only ftp as the source itself.

I want to create a loop on the local website where my photos will alternate. The source of this loop will be the ftp server.

I don't know how to do it without downloading data. Is it even possible? Thanks

I connected to ftp with this command:

 <?php 
$host =  "xxx" ;
$user  =  'xxx' ;
$password  =  'xxx' ;
$ftpConn  =  ftp_connect ( $host ) or die("Nepodařilo se připojit k $host");;
$login  =  ftp_login ( $ftpConn , $user , $password ) ;

if(ftp_login ( $ftpConn , $user , $password )){
  echo "Přihlášení k FTP proběhlo v pořádku!";
}
else{
  echo "Přihlášení k FTP neproběhlo v pořádku!";
}

ftp_pasv($ftpConn, true);

// get file list of current directory
$file_list = ftp_nlist($ftpConn, ".");
var_dump($file_list);

// close connection
ftp_close($ftpConn);

?>

The connection was successful. The data were also located here.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • See [Retrieve image from FTP to webpage](https://stackoverflow.com/q/17169251/850848). – Martin Prikryl May 11 '20 at 05:24
  • This proposal is not bad. I just have more png files. I can't have a new php script for every slide. – Ondřej Skládal May 11 '20 at 10:17
  • Of course not. You pass the name to the script in URL query string – Like here: [List and download clicked file from FTP](https://stackoverflow.com/q/52855025/850848). – Martin Prikryl May 11 '20 at 10:22
  • I'm sorry but I'm a complete beginner in php. I can't understand it. This is my php file: `` And in html i call `` How exactly can I add another image to php? And how do I call in html ? Thank you. – Ondřej Skládal May 11 '20 at 19:57
  • `` => `echo file_get_contents('ftp://aladin.mysteria.cz:xxx@aladin.mysteria.cz/mesic/1/'.$_GET["filename"]);` – Martin Prikryl May 11 '20 at 20:28

0 Answers0