In silex, I can do this to force the download of a file:
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; $app = new Silex\Application(); // Url can be http://pathtomysilexapp.com/download $app->get('/download', function (Request $request) use ($app) { $file = '/path/to/download.zip'; if( !file_exists($file) ){ return new Response('File not found.', 404); } return $app->sendFile($file)->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'download.zip'); }); $app->run();
This works well for small files. However, my use case requires downloading a large file, which can be paused / resumed by the download manager.
There is an example streaming file, but it doesn't seem to be what I'm looking for. Has anyone done this before? I could just use the answer from here and do it. But it would be nice if it were silexy.
source share