简体   繁体   English

通过PHP用wget下载音频

[英]download audio with wget over php

I am trying to download audio file over php. 我正在尝试通过php下载音频文件。 I have tried download it with curl and wget. 我尝试用curl和wget下载它。 here are examples: 以下是示例:

<?php
  exec('wget http://static1.grsites.com/archive/sounds/cartoon/cartoon001.wav');
?>

How can I download it by using one of two mentioned methods. 如何使用上述两种方法之一下载它。

I think this should work for you: 我认为这应该为您工作:

<?php
    $url = 'http://static1.grsites.com/archive/sounds/cartoon/cartoon001.wav';
    header('Content-Type: audio/wav');
    header('Content-Disposition: inline;filename="name.wav"');
    header('Content-length: '.get_headers($url,1)['Content-Length']);
    header('Cache-Control: no-cache');
    header("Content-Transfer-Encoding: chunked");
    readfile("http://static1.grsites.com/archive/sounds/cartoon/cartoon001.wav");
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM