1

I tried to display a picture stored in the public_ftp folder of my hosting domain as follow

$connect = ftp_connect("ftp.mydomain"); 
$result = ftp_login($connect, "username", "password");
$a = ftp_nlist($connect, "myfolder");
foreach($a as $value){
    echo "<img src='".$value."'></img><BR>";}

another attempt

echo "<img src='ftp://username:password@mydomain.org/myfolder/mypicture.png'> </img>"

myfolder is located in public_ftp not in public_html.

can anyone have an idea on how to display a pictures stored in ftp server?

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • 1
    Read this: [Retrieve image from FTP to webpage](https://stackoverflow.com/questions/17169251/retrieve-image-from-ftp-to-webpage). You need to serve the data via HTTP, that's the bottom line. So make sure you move the images to the right place when you deploy them to the server. – ADyson Oct 04 '22 at 13:35
  • @ADyson when i move the pictures to public_html work fine without the needs to connect to the ftp server. i dont want to moves the pictures to public. does any solution exists to display the pictures ? – TIgrine nacer Oct 04 '22 at 13:49
  • How is anyone on your website supposed to access them then, if they're not public? The whole point of a website is that the contents of it are public...why wouldn't you want to move them to public_html (or a subfolder underneath that)? – ADyson Oct 04 '22 at 13:51
  • not all contents on websites are public look at instgram twitter facebook... )-: – TIgrine nacer Oct 04 '22 at 13:54
  • Yes that's true. So you want only certain people to have access to them? You didn't mention this requirement in your question. In that case you can store them somewhere private, but then the `src` in your HTML must contain the URL of a PHP script, which, when it receives a request (which should contain something to identify the required image file in its querystring), checks first if the current user has permission to view that image file, before then setting the appropriate response headers and returning the contents of the file - or causing an error instead, if they have no permission. – ADyson Oct 04 '22 at 13:58

0 Answers0