Prompt user to open or save when delivering file data stored in database with PHP

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

This set of headers works for me when I output file data from the database for the user to save or open.

Copy this code and paste it in your HTML
  1. <?
  2. header("content-type: $mime_type");
  3. header("content-disposition: attachment; filename=$file_name");
  4. header("cache-control: private");
  5. header("pragma: private");
  6. echo $file_data;
  7. ?>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.