rubahfgouveia Posted October 18, 2010 Share Posted October 18, 2010 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 More sharing options...
Colton.Wagner Posted October 18, 2010 Share Posted October 18, 2010 Could it be as easy as: $file ='./ExampleFile/Files/blabla.gif'; I didn't even test it but I have used that before. Thanks, Colton Wagner Link to comment https://forums.phpfreaks.com/topic/216131-php-readfile/#findComment-1123232 Share on other sites More sharing options...
rubahfgouveia Posted October 18, 2010 Author Share Posted October 18, 2010 worked as a charm. thanks alot Link to comment https://forums.phpfreaks.com/topic/216131-php-readfile/#findComment-1123249 Share on other sites More sharing options...
Colton.Wagner Posted October 18, 2010 Share Posted October 18, 2010 Not a problem good luck with your endeavors! Thanks, Colton Wagner Link to comment https://forums.phpfreaks.com/topic/216131-php-readfile/#findComment-1123251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.