Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! TheMayhem's Avatar
    Join Date
    Apr 2007
    Location
    Sweden
    Posts
    34

    Accessing pictures outside of www with php on apache


    Hello,

    I'm running apache and using php to deliver a page. I am using a function to randomly serve a picture through a php page (/var/www/html/pf/randompicture.php) when called as such:
    PHP Code:
    <?php
    // open the file in a binary mode

    function random_pic($dir 'apa')
    {
        
    $files glob($dir '/*.*');
        
    $file array_rand($files);
        return 
    $files[$file];
        
    }

    $name random_pic();

    $fp fopen($name'rb');

    // send the right headers
    header("Content-Type: image/jpeg");
    header("Content-Length: " filesize($name));

    // dump the picture and stop the script
    fpassthru($fp);
    exit;
    ?>
    I have granted the Apache user access to the apa folder and pictures within it and it works fine.

    But now I want to replace the folder 'apa' with a symlink to a folder outside of www, more specifically /shares/bilder/Wille

    I have tried reading up on it and messed around with <Directory> ans <Alias> tags in the Apache config, I've added a symlink to the /shares/bilder/Wille folder, I've set access rights on both symlink and the real folder/files but nothing works. The glob returns an empty array whatever I do.

    I'm assuming I'm simply not able to set it up correctly with the correct configuration of all the above. So.. I'm hoping someone where can give me instructions on how to get it to work.

    Thanks in advance!

  2. #2
    I am not a "Linux Guru"! Get off me! The Forum software won't let me change it!
    How to ask smart questions | Don't be a Help Vampire | How to Use Code Tags
    You can post a link by removing "http://www." from it.

  3. #3
    Just Joined! TheMayhem's Avatar
    Join Date
    Apr 2007
    Location
    Sweden
    Posts
    34
    Quote Originally Posted by nihili View Post
    You are correct. Are you simply pointing it out or is it not ok to post in more than one forum?

    For everyone else - I'm closing this thread since I got it working. I can't say I know exactly how but a combination of the correct <Directory> tags in apache config, removing a broken .htaccess file (thansk to /var/log/apache2/error.log and mostl likely some more access right configurations.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •