I'm fooling around with a *very* basic file browsing system, and I'm to make it possible that you can view the contents of a file from the browser. The code above is the piece that should display it.PHP Code:echo '<br><br>';
echo '<b>Contents:</b><br>';
$filebase = basename($file); //get just the file name itself
$file_read_dir = '/home/virtual/site11/fst/var/www/html/practice/php/' . $filebase; // put it back with the rest of the directories
echo '<br>' . $filebase;
echo '<br>' . $file_read_dir;
$file_open = fopen($file_read_dir, 'r');
if (!$file_open)
{
echo '<br>Error opening file.';
}
$read = fread( $file_open, '' );
echo $read;
if (!$read)
{
echo '<br>Error reading file.';
}
fclose($file_open);
I don't know if I'm going about this the right way or not, but when I tried to view the file, it simply echo'd out "Resource id #2", and on one instance it echo'd out "Resource id #1".
I'm just a tad confuzzeled here =\
-Jg





Bookmarks