Jump to content

Readfile() warning


nats

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.