如何强制从外部主机下载?

时间:2019-04-21 12:51:16

标签: php curl mp3 external force-download

如何强制从外部主机下载?默认情况下,它已在台式机和移动设备上运行,但最近停止在移动设备上运行。通过.htaccess文件强制执行该操作无效。

我搜索并找到了两种可能的解决方案-一种是使用CURL,另一种是使用PHP。我倾向于PHP。这两个解决方案位于herehere

使用PHP方法创建了此文件:

$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;

我将其命名为download.php。但是,我不知道将此文件放在何处。我将其上传到public_html文件夹,但这没有任何作用。

0 个答案:

没有答案