infowire Posted March 10, 2017 Share Posted March 10, 2017 Hello, i have a question, why do my variables $ don't work here? How to get them to work ? if(isset($_POST['click'])) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header("Content-Disposition: attachment; filename=" . $orig); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); echo $link_download; ob_clean(); flush(); echo file_get_contents($link_download); }; Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted March 10, 2017 Share Posted March 10, 2017 *sigh* Can you be a bit more specific than “doesn't work”? Have you printed the variable content to see if it's even correct? According to the HTTP standard, the filename must be quoted. As in: Content-Disposition: attachment; filename="foo" Firefox seems to happily accept unquoted filenames, but it will stop after the first space character. Quote Link to comment Share on other sites More sharing options...
infowire Posted March 10, 2017 Author Share Posted March 10, 2017 i found the first problem, my stupidity. Calling for $ when they have not been defined yet. Now it downloads example.jpg and it can't display... Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 11, 2017 Share Posted March 11, 2017 When you have the browser download a file, it is not going to treat it like a standard image. Any such handling would be left to the operating system. Quote Link to comment 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.