How to force download via remote url to any File type

Asked

Viewed 2,558 times

2

I would like to know how I can force download via remote url to any type of file being my priority in case I force download of online video media files. For example this url in question Url of mentioned here

From now on I thank anyone who can help me.

  • How so force?

  • Force the download of this file because the url in question opens an online player I want to do in case this link instead of opening the video player he downloads the file in question.

  • Actually, this didn’t help you http://answall.com/a/80516/3635 ?

  • Unfortunately it was not blocking the direct download.

  • Rodrigo, as for your request to the moderators, take a look here.

2 answers

2

You can try something like:

<?php
 $file_name = 'mov_bbb.mp4';
 $file_url = 'http://www.w3schools.com/html/' . $file_name;
 header('Content-Type: application/octet-stream');
 header("Content-Transfer-Encoding: Binary");
 header("Content-disposition: attachment; filename=\"".$file_name."\"");
 readfile($file_url);
 exit;

Tested and worked for me, you just put the video path and the php force the download of it, so that it works and necessary that fopen_wrappers qualified.

I found the answer here

2


You can do with HTML only, using the attribute download on the tag <a>.

<a href="http://www.anistream.ga/videos/1352868579.mp4" download="http://www.anistream.ga/videos/1352868579.mp4">LINK</a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.