nats Posted January 29, 2009 Share Posted January 29, 2009 Frndz I need ur help urgently... I am not able to open the file which has been downloaded from the server... The download dialogue works perfectly fine but on opening the file I get the following warning: Warning: readfile($filePath) [function.readfile]: failed to open stream: No such file or directory in ...... Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted January 29, 2009 Share Posted January 29, 2009 From the looks of the error, it seems the path to the file is wrong. More information is needed to actually trouble shoot the problem though. Specifically, the code that is being executed would be helpful. Quote Link to comment Share on other sites More sharing options...
nats Posted January 29, 2009 Author Share Posted January 29, 2009 here is the code: <?php $dbcon = mysql_connect("localhost", "root", ""); mysql_select_db("xyz", $dbcon); $id = $_GET['id']; $query = "SELECT name, ext, size, path FROM uploads WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($fileName, $fileType, $fileSize, $filePath) = mysql_fetch_array($result); echo $filePath; header("Content-Disposition: attachment; filename=\"$fileName\""); header("Content-length: $fileSize"); header("Content-type: $fileType"); readfile('$filePath'); ?> Quote Link to comment Share on other sites More sharing options...
godsent Posted January 29, 2009 Share Posted January 29, 2009 Remove the quotes, and leave like this: readfile($filePath); Quote Link to comment Share on other sites More sharing options...
nats Posted January 30, 2009 Author Share Posted January 30, 2009 Hey thanks a lot......... The download works fine; but now again there is another problem.. While downloading a PDF file, it says an unknown file type...but after downloading, if I open it with Acrobat, the file opens successfully... This happens only with PDF files & not with any other file extension. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.