I made a form to upload files to the folder ./data/uploads
using the Zend\Filter\File\RenameUpload
filter.
This is working like a charm. My problem now is how do I provide this file to users download it?
I think it would be something like:
$response->setContent(file_get_contents('./data/uploads/file.png'));
But I want to know what is the best way to do this.
Thanks to @henrik for response, but several important headers are missing in his answer. Be careful of that.
Full headers stack:
For anyone who bumps into this thread looking for an answer, this is a solution that works, and it's using streams!
Found here: force download using zf2
More details here: sending stream responses with zend