Paulio Posted May 30, 2010 Share Posted May 30, 2010 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. Link to comment https://forums.phpfreaks.com/topic/203367-help-including-files-outside-of-webpublic_html-folders/ Share on other sites More sharing options...
Mchl Posted May 30, 2010 Share Posted May 30, 2010 You can't display an image that is not within your webroot. What you need to do, is to write a script that will fetch a file from this location, and send it to browser with aprropriate headers, like: <?php $MovieDir = "/c/Movies/The.Taking.of.Pelham.1.2.3[2009]/"; $CoverFile = $MovieDir . "cover.jpg"; header('Content-type: image/jpg'); readfile($CoverFile); ?> save it as picture.php Then in your main script use echo "<img src='picture.php'></tr></td></table>"; Link to comment https://forums.phpfreaks.com/topic/203367-help-including-files-outside-of-webpublic_html-folders/#findComment-1065464 Share on other sites More sharing options...
Paulio Posted May 30, 2010 Author Share Posted May 30, 2010 You can't display an image that is not within your webroot. What you need to do, is to write a script that will fetch a file from this location, and send it to browser with aprropriate headers, like: <?php $MovieDir = "/c/Movies/The.Taking.of.Pelham.1.2.3[2009]/"; $CoverFile = $MovieDir . "cover.jpg"; header('Content-type: image/jpg'); readfile($CoverFile); ?> save it as picture.php Then in your main script use echo "<img src='picture.php'></tr></td></table>"; This is exactly what ive been looking for!! Thanks! Link to comment https://forums.phpfreaks.com/topic/203367-help-including-files-outside-of-webpublic_html-folders/#findComment-1065476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.