0

basic html code user here, just trying to get some scripts finished up and im struggling.

I have a hosted website, and a hosted dedicated server. I have a folder on my dedicated server full of pictures (screenshots) from server players that gets taken randomly. Its for anti cheat.

Basically, ive been trying to write a script so that on a webpage on my hosted website, it automatically shows all the pictures from that folder on my dedi. Im struggling.

The only code i know to show a picture from ftp is

img src="ftp://username:password@my_ftp_ip_address/Images/imagename.jpg"

I want to create something that automatically shows all the pictures or at least lists the folder directory so that i can click on the pictures, but im a bit confused on how to do this! Any help would be great thanks!

Brenden Rodgers
  • 253
  • 1
  • 3
  • 5
  • is the dedicated server accessible via a webpage? so IP address etc, so could you not use the ip or if it's got a domain name to get the image, i wouldnt do that ftp why as that will open your password and details to the public masive security risk – Simon Davies Aug 09 '17 at 22:27
  • Why not copy the images to your web server? – Ed Heal Aug 09 '17 at 22:29

2 Answers2

2

This is basically an anti-pattern. You shouldn't be exposing your username and password in your HTML code.

One thing you can do, is set up a web server on your FTP server so instead of <img src="ftp://..." /> you'll be using <img src="https://my-server.com/image.jpg" />

For example you can set up nginx or apache to serve the images from a certain directory but prevent directory listings.

For nginx, you can either follow the official docs, or get a hint from this SO Question

Same thing with apache, you can pick whichever you find that fits your needs best.

Fotis
  • 1,322
  • 16
  • 30
0

With using <img src""></img> you can target the folder directly without having to insert a link. Like so: <img src"<folder holding images>/<image name>" /> this should target the photo you are looking for without having to expose your username, password, and FTP information.

If you want to show all images it needs to be defined in your HTML, you need to use the code above to target each image individually (Helps organization).

If you want to be able to click on the photos you can add <a href="mywebsite.com/imagefolder/imagename"></a> and that should allow you to click on the image and then open it in a bigger version. If you want to make it open in a new tab add this target="_blank" to your <a></a> tag so that way it opens in a new tab.

S. Super
  • 1
  • 1