1

I have this php code that helps user to download a file from database. But the downloadable file is downloaded directly into default computer download folder. What I want is to popup a box to ask the user where to save the file, so if their any help. Thank You.

<?php
$data = $_REQUEST['data'];
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
//header("Content-disposition: attachment; filename=\"" . basename($data) . "\"");
header("Content-disposition: attachment; filename=\"" . basename($data) . "\"");
readfile($data);
?>
chris85
  • 23,846
  • 7
  • 34
  • 51
alim1990
  • 4,656
  • 12
  • 67
  • 130
  • This seems very insecure, a user can put in any path as `$_REQUEST['data']` and then you allow them to download your files? – chris85 Oct 19 '15 at 13:06
  • it is an intranet web so only 2 users want to see it. Any help ? – alim1990 Oct 19 '15 at 13:10
  • Have you found [this answer](http://stackoverflow.com/questions/8485886/force-file-download-with-php-using-header) to be of any use for your? – Jan Oct 19 '15 at 13:14
  • 1
    It's browser behavior, not server-side. If user selects to auto-save - you can't change it. – Justinas Oct 19 '15 at 13:21
  • Yes I think you are right. I will put a remarc that said for specific directory right click and then click on save link as. Thank You. – alim1990 Oct 19 '15 at 14:05

0 Answers0