rrayner Posted June 25, 2012 Share Posted June 25, 2012 I have the following code thanks to php.net which downloads a file from the server and I was wondering if you can force it to download into a certain directory? <?php $file = '317.txt'; 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'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } ?> Thanks Rob. Quote Link to comment https://forums.phpfreaks.com/topic/264728-force-a-file-to-a-certain-directory-when-downloading/ Share on other sites More sharing options...
requinix Posted June 25, 2012 Share Posted June 25, 2012 I was wondering if you can force it to download into a certain directory? Nope. Quote Link to comment https://forums.phpfreaks.com/topic/264728-force-a-file-to-a-certain-directory-when-downloading/#findComment-1356769 Share on other sites More sharing options...
rrayner Posted June 25, 2012 Author Share Posted June 25, 2012 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264728-force-a-file-to-a-certain-directory-when-downloading/#findComment-1356776 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.