Problem in reading a file from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robin1983
    New Member
    • Oct 2007
    • 99

    Problem in reading a file from database

    Hi guys, i have a php file to read to content, the following is the code
    [PHP]
    <?php
    include "config.inc.php ";
    include "connect.inc.ph p";

    if(isset($_GET['id']))
    {
    $id = $_GET['id'];
    $query = "SELECT filename, filetype, filesize, content FROM candidate_table where id = '$id'";
    $result = mysql_query($qu ery) or die(mysql_error ());

    list($filename, $type, $size, $content) = mysql_fetch_arr ay($result);
    $file = fopen($filename ,"r") or exit("unable to open");
    echo "<div style=\"border: 1px blue solid; \">";
    while(!feof($fi le))
    {
    echo fgets($file);
    }
    fclose($file);
    echo "</div>";
    /*
    header("Content-length:$size");
    header("Content-type:$type");
    header("Content-Disposition:att achment; $filename=$name ");
    echo $content;*/
    exit;
    }

    ?>
    [/PHP]
    but, when run the scripts, it showing the following error,

    [HTML]
    Warning: fopen(drgulrez[02,00][2].doc) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\dr_ resume_databse\ cv.php on line 12
    unable to open
    [/HTML]
    i m not able to fine the solution, if any one can help, plz help me thanks
  • coffear
    New Member
    • Nov 2007
    • 20

    #2
    presumably drgulrez[02,00][2].doc is actually a file? Also it might be best using a server path to the file in fopen as well.

    Comment

    • robin1983
      New Member
      • Oct 2007
      • 99

      #3
      Yes, this is the file, when i run other php file to download the same file its working properly, but when i try to open the same file its giving the warning that i posted earlier. and how to used server path...i dont have idea for that plz help...

      Originally posted by coffear
      presumably drgulrez[02,00][2].doc is actually a file? Also it might be best using a server path to the file in fopen as well.

      Comment

      • assimlation
        New Member
        • Nov 2007
        • 9

        #4
        on the line after your list() function call you could manip your filename variable to have the path included.. ie:

        $filename = "C:\wamp\www\dr _resume_databse \" . $filename;

        Comment

        • robin1983
          New Member
          • Oct 2007
          • 99

          #5
          Thanks.. for the reply.. . i got the solution.. and thanks for guiding me ...
          Originally posted by assimlation
          on the line after your list() function call you could manip your filename variable to have the path included.. ie:

          $filename = "C:\wamp\www\dr _resume_databse \" . $filename;

          Comment

          Working...