Jump to content

PHP readfile


rubahfgouveia

Recommended Posts

Hey, having some troblems using the readfile function..

 

I have the following code. I want to download the file "blabla.gif", but the file is in a certain directory (let's say: "/ExampleFile/Files/" .

 

How do I set the path to "/ExampleFile/Files/" ?

 

 

$file ='blabla.gif';


if (file_exists($file)) {

    header('Content-Description: File Transfer');

    header('Content-Type: application/octet-stream');

    header('Content-Disposition: attachment; filename='.basename($file));

    header('Content-Transfer-Encoding: binary');

    header('Expires: 0');

    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

    header('Pragma: public');

    header('Content-Length: ' . filesize($file));

    ob_clean();

    flush();

     readfile($file);

    exit;

}

 

 

Thanks, Ruben

Link to comment
https://forums.phpfreaks.com/topic/216131-php-readfile/
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.