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
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
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
Share on other sites

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.