How can I force downloads from external host?

97 views Asked by At

How can I force a download from an external host? It had been working by default on desktop and mobile but recently stopped working on mobile. Forcing it via .htaccess file does not work.

I searched and found two possible solutions - one is by using CURL and the other PHP. I'm leaning towards PHP. These two solutions are located here and here

Using the PHP method I created this file:

$file_name = 'file.mp3';
  $file_url = 'https://partyfavorz.podbean.com/' . $file_name;
  header('Content-Type: application/octet-stream');
  header("Content-Transfer-Encoding: Binary"); 
  header("Content-disposition: attachment; filename=\"".$file_name."\""); 
  readfile($file_url);
  exit;

I named it download.php. However, I do not know where to place this file. I uploaded it to the public_html folder but that had no effect.

0

There are 0 answers