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 ...... Link to comment https://forums.phpfreaks.com/topic/142932-readfile-warning/ 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. Link to comment https://forums.phpfreaks.com/topic/142932-readfile-warning/#findComment-749393 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'); ?> Link to comment https://forums.phpfreaks.com/topic/142932-readfile-warning/#findComment-749443 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); Link to comment https://forums.phpfreaks.com/topic/142932-readfile-warning/#findComment-749453 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. Link to comment https://forums.phpfreaks.com/topic/142932-readfile-warning/#findComment-750562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.