Dynamic creation of a file and immediate download


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $file = "exported_data.txt" ;
  2. // open a file to export data ...
  3. $open = fopen($file,"w+") ;
  4. // write selected exported data to a file ..........
  5. fwrite($open,$exported_data);
  6. fclose($open);
  7. // download ...
  8. header("Content-Type: application/octet-stream");
  9. header("Content-disposition: attachment; filename=exported_data.txt");
  10. print($export_affiliate_data);
  11. exit();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.