0

Hi I am trying to provide access to a folder of photos. The website is Unix based so I can change permissions. I am using WISE-FTP 8 as my FTP program. I created a directory on the server and intend to upload about 40 photos to it. I uploaded one photo as a test and received a 403 Forbidden. The directory is set to public read.

2
Contributors
16
Replies
47
Views
3 Years
Discussion Span
Last Post by Aeonix
Featured Replies
  • Okay, this is my final answer, if this can't solve your issue, I can't really help you: 1. First off, be entirely sure, your Linux installation allows both your folder AND your image, a public access. 2. Second of all, update your script to this: <?php $images = glob("*.png"); $folderRoot … Read More

0

Is the folder of photos within a server directory (htdocs or www)?

If so, you can create folder, put your pictures in it, and then refer your visitors to the folder. Keep in mind to not create any home, index or default page. As soon as server doesn't have these files, it will list every file in that directory. In such form (a little bit outdated):
http://www.askdavetaylor.com/0-blog-pics/apache-directory-listing.png

In case, when the folder is out of the reach of htdocs or www. You could go to folder where you have your images (for example cd /home/me/), then use ll commands and ls -l or ll. And give us your output.

Your directory may be free to be read by public, but your files may not be.

Alternatively you could always make index.php with:

$imgdir = "PATH_TO_YOUR_IMAGES_FOLDER";
$images = glob($imgdir . "*.jpg");

foreach($images as $linkto) {
    echo "<a href=$linkto>".basename($linkto)."</a><br />";
}

This code is not yet tested so it may not work perfectly well. Try to put this into your images file.

Edited by Aeonix

0

Thanks Aeonix

Its an htdocs (Fasthosts hosted) I have created the folder and uploaded it to my website but it won't allow me to open it in a browser. The folder only has at present one jpg file. Shall I try to add the your index file as you suggest to the image folder?

Thanks Geoff

Edited by ggeoff: added info

0

Yes, try this, if you configure file correctly (that is, modifying paths and names), it should be able to see all the files and list their links and by clicking those links, you will be sent to these photos.

If this wouldn't work, I suggest we may use TeamViewer to solve your issue. It's a program that would temporarily allow me control of mouse and keyboard, I would then be able to set up basic "file reader" and I would let you work onward with it.

If you're interested in that solution, download and install it and pass me the number and PIN (of the program) through private message. Don't be worried, if you feel like I'm bluffing or doing something wrong that I wasn't supposed to do, it's as easy as closing window.

Edited by Aeonix

0

Thanks. I have got as far as the jpg file being listed in the browser window using your code. Its address is mywebsite/images which is correct. If I click the link I get a message: Not Found The requested URL . . .was not found on this server. In the browser's address Go To Box the website path is displayed but starts from the website's URL and adds on the full path. My path to the images folder is the complete one on the server that I copied from the Security_health_check.log.

Edited by ggeoff: clarified

0

Sorry, I don't, understand.

  1. What is absolute (full) address (browser) path to that one image?
  2. What is absolute (full) address (browser) path to folder of image?
  3. What is the address that you go to when you click on the link?
  4. What is the address, when you copy links destination?
  5. Where is this all located on your HDD? (full address please).
0

1 What is absolute (full) address (browser) path to that one image?
2 What is absolute (full) address (browser) path to folder of image?
3 What is the address that you go to when you click on the link?
4 What is the address, when you copy links destination?
5 Where is this all located on your HDD? (full address please).

  1. www.mywebsite/images/index.php
  2. www.mywebsite/images
  3. www.mywebsite/home/linweb38/f/mywebsite-1234../htdocs/images/photo.jpg
  4. same as 3 above
    5 the jpg is on my website's server in the images folder (directory)

    I thought that the path to my images folder would be /htdocs/images/ but couldn't get it to work. It was only when I added the full path that the link for the photo was displayed on my browser window. So your code finds the jpg file and displays a link for it, but the link doesn't work yet.

Edited by ggeoff: typo

0

Hmmmm...

$fileSelf = pathinfo(__FILE__);
$folderRoot = $fileSelf["dirname"]

$images = glob($folderRoot . "*.jpg");

foreach($images as $linkto) {
    $imageSelf = pathinfo($linkto);
    $suffixToAdd = $imageSelf["filename"] . $imageSelf["extension"];
    echo "<a href=" . $folderRoot . $suffixToAdd . ">" . $suffixToAdd . "</a><br />";
}

Could this work? If not, could you repeat those 5 questions again in this case?

0

Thanks Aeonix which are place holders that I need to add actual folder names to. Just to clarify this index file only has your code in PHP tags.

0

which are place holders that I need to add actual folder names to.

I don't understand, sorry. May you please explain?

0

I have replaced "dirname" with "images" that being my folder name for the images. Is that correct and do I need to alter anything else?

0

This script was actually ready-thing, you hadn't replace anything.

Could this work? If not, could you repeat those 5 questions again in this case?

I meant, run this script, look if it works for thine purposes. If it doesn't, I requested you repeating these 5 researches:

What is absolute (full) address (browser) path to that one image?
What is absolute (full) address (browser) path to folder of image?
What is the address that you go to when you click on the link?
What is the address, when you copy links destination?
Where is this all located on your HDD? (full address please).

The last script I provided, was a ready thing, nothing had to be changed.

Edited by Aeonix

0

I have amended the script to what you posted. Nothing is displayed, blank browser window. Address in browser mywebsite/images/

0

Oops, made a typo, sorry, try this one:

$fileSelf = pathinfo(__FILE__);
$folderRoot = $fileSelf["dirname"];
$images = glob($folderRoot . "*.jpg");
foreach($images as $linkto) {
    $imageSelf = pathinfo($linkto);
    $suffixToAdd = $imageSelf["filename"] . $imageSelf["extension"];
    echo "<a href=" . $folderRoot . $suffixToAdd . ">" . $suffixToAdd . "</a><br />";
}
1

Okay, this is my final answer, if this can't solve your issue, I can't really help you:

  1. First off, be entirely sure, your Linux installation allows both your folder AND your image, a public access.
  2. Second of all, update your script to this:

    <?php

    $images = glob("*.png");
    $folderRoot = "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]);
    
    foreach($images as $imageName) {
        $imageUrl = $folderRoot . "/" . $imageName;
        echo "<a href=" . $imageUrl . ">" . $imageName . "</a><br />";
    }
    

    ?>

  3. Make sure this script lands amongst images.

Edited by Aeonix

0

Thanks very much Aeonix but I was getting a Forbidden using the last two scripts. You don't have permission to access /images/ on this server.

Update:

I have checked the permissions for the directory and the file and set them to
Directory for the images 777, index.php 766, and 766 for the file. The script is working now.

Thanks very much for this help :)

Edited by ggeoff: more info

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.