We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Download video (video/mp4) with given id in the database

I have created small/simple a video-sharing site with videojs, but I also want to add a feature where I can download the currently playing video. But I'm struggle to get start on it. Right now, each video is playing by passing in its correct id. (in the database, i got id, filename (video source), thumbnails, duration). Could I do something like this: View:

<a href="<?= $this->url->get("index/download/".$video->id) ?>"> <button style="position:relative; right:-665px; top:-20px;" type="button" class="btn btn-primary">Download Current Video</button> </a>

and in the IndexController, have something like this

public function downloadAction($id) { //possibly needs help here? }

Thanks for any help.



43.9k
edited Aug '16

Hi,

You can use Phalcon\Http\Response, especially, the setHeader and setContent.

Also disable the view in your function downloadAction.