Results 1 to 4 of 4

Thread: Help including files outside of web/public_html folders

  1. #1

    Thread Starter
    Junior Member rrafluap's Avatar
    Join Date
    Sep 2009
    Location
    Plymouth, England.
    Posts
    23

    Help including files outside of web/public_html folders

    Hey, on my readynas duo i have a share called movies, inside the movies share there are hundreds of subdirectories each with a movie file (mostly avi), a txt file (Details.txt) and an image (cover.jpg)

    i am trying to list the contents using a php script, so far i can get the info from the text file but not the image as its not in my web share...

    Here is what i have:

    <?
    $MovieDir = "/c/Movies/The.Taking.of.Pelham.1.2.3[2009]/";
    $DetailsFile = $MovieDir . "Details.txt";
    $CoverFile = $MovieDir . "cover.jpg";


    $fh = fopen($DetailsFile, 'r');
    $theData = fread($fh, filesize($DetailsFile));
    fclose($fh);
    $delimiter ="@";
    list($title, $year, $genre, $plot, $tag, $imdb, $created) = explode($delimiter, $theData);


    echo "<table border='1'><tr><td>";
    echo "<b>Title:</b> $title<br>";
    echo "<b>Year:</b> $year<br>";
    echo "<b>Genre:</b> $genre<br>";
    echo "<b>Plot:</b> $plot<br>";
    echo "<b>Tagline:</b> $tag<br>";
    echo "<b>IMDb:</b> $imdb<br>";
    echo "<b>Created:</b> $created<br>";
    echo "</td><tr>";
    echo "<img src='" . $CoverFile . "></tr</td></table>";
    //echo $theData;
    ?>
    Obviously the last image tag is incorrect but you can see what i am trying to acomplish by what i have typed there, is there a function in php that will alow me to include it/load it into a variable etc... for use as the web path is "/c/web..." and the movies are in "/c/movies..." etc...


    Thanks, Paul.
    Last edited by rrafluap; May 30th, 2010 at 02:45 PM.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Help including files outside of web/public_html folders

    so long as the path is the absolute URI to the image, it should work fine -- especially if you're already able to open the text file. look at the path that it's creating and try opening it in your browser -- it would be looking for a path similar to: http://localhost/c/Movies/The.Taking.of.Pelham.1.2.3[2009]/cover.jpg.

    you're missing an end quote for the src attribute of your <img> tag, also.

  3. #3

    Thread Starter
    Junior Member rrafluap's Avatar
    Join Date
    Sep 2009
    Location
    Plymouth, England.
    Posts
    23

    Re: Help including files outside of web/public_html folders

    Quote Originally Posted by kows View Post
    so long as the path is the absolute URI to the image, it should work fine -- especially if you're already able to open the text file. look at the path that it's creating and try opening it in your browser -- it would be looking for a path similar to: http://localhost/c/Movies/The.Taking.of.Pelham.1.2.3[2009]/cover.jpg.

    you're missing an end quote for the src attribute of your <img> tag, also.
    that wont work though because that would mean the path to the cover file would be /c/web/c/movies/The.Taking.of.Pelham.1.2.3[2009]/cover.jpg because /c/web is the location of the php script and the movies folder is a completely different folder

    i hope that makes sense

  4. #4

    Thread Starter
    Junior Member rrafluap's Avatar
    Join Date
    Sep 2009
    Location
    Plymouth, England.
    Posts
    23

    Re: Help including files outside of web/public_html folders

    Found what i needed...

    create a file called picture.php:
    <?php
    $MovieDir = "/c/Movies/The.Taking.of.Pelham.1.2.3[2009]/";
    $CoverFile = $MovieDir . "cover.jpg";
    header('Content-type: image/jpg');
    readfile($CoverFile);
    ?>

    then use the image source as picture.php

    Thanks, Paul.

Posting Permissions

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



Click Here to Expand Forum to Full Width