Skip to content

Instantly share code, notes, and snippets.

@frankdejonge
Created June 10, 2014 18:38
Show Gist options
  • Save frankdejonge/5c19f8e7ce329dbcc1ef to your computer and use it in GitHub Desktop.
Save frankdejonge/5c19f8e7ce329dbcc1ef to your computer and use it in GitHub Desktop.
Flysystem and user downloads
<?php
$stream = $fs->readStream($file);
// send the right headers
header("Content-Type: " . $fs->getMimetype($file));
header("Content-Length: " . $fs->getSize($file));
header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
// dump the attachement and stop the script
fpassthru($stream);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment