Force downloadable


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

Force downloadable file with php


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. //Link to download file with <a href="download.php" target="_blank">Download</a>
  4.  
  5. header('Content-disposition: attachment; filename=huge_document.pdf');
  6. header('Content-type: application/pdf');
  7. readfile('huge_document.pdf');
  8. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.