Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP force download of remote file without reading into memory
  2. if($url = getRemoteFileURL($file_id))
  3. {
  4.   header('Content-Type: application/octet-stream');
  5.   header('Content-Disposition: attachment; filename="abc.zip"');
  6.   header('Content-Transfer-Encoding: binary');
  7.   header('Expires: 0');
  8.   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  9.   header('Pragma: public');
  10.   header('Pragma: no-cache');
  11.  
  12.   readfile($url);  // is there a better function ?
  13. }