Jump to content

Recommended Posts

Hi Guys,

 

when a user uploads to my site they can upload doc files and i store the doc files in a docs folder and store:

 

file.doc in the database, when i try to read the file it only displays the filename and not the content here my code:

 

     $filename = "docs/$docs"; 
     $fd = fopen ($filename, "r"); 
     $contents = fread ($fd, filesize($filename)); 
     fclose ($fd);
     
     echo $doc;  

 

amy help would be appreciated

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/51621-solved-reading-files-stored-in-mysql/
Share on other sites

Hi Mate,

 

heres my code:

 

     $query = "SELECT * FROM `nfos` WHERE `id`='$id'";
    $result = mysql_query($query) or die (mysql_error());
    $row = mysql_fetch_array($result) or die (mysql_error());
    
    // get the nfo file...//////////////////////////////////////////////////////////////
    $nfo = $row['nfo'];
    
    //$filename = "nfos/$nfo"; // This is at root of the file using this script.
    //$fd = fopen ($filename, "r"); // opening the file in read mode.
    //$contents = fread ($fd, filesize($filename)); // reading the content of the file.
    //fclose ($fd);
    
    $fd = fopen($nfo, "are") or die ("Can't Open File");
    $contents = fgets($fd);
    fclose($fd);
    echo $contents;
    
    //echo $nfo; 
    echo "<br /><br />";  

 

i have tried .nfo and .doc files they both seem to ech out the name of the file rather than the contents, is it maybe my coding?

 

Graham

 

cheers

 

Graham

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.