SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with fopen()

    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'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.

    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

  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have a look at fpassthru() and file_get_contents() on php.net. They explain the problem...
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  3. #3
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by weirdbeardmt
    have a look at fpassthru() and file_get_contents() on php.net. They explain the problem...
    Aaah, much thanks!


Bookmarks

Posting Permissions

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