用wget通过php下载音频 [英] download audio with wget over php

查看:52
本文介绍了用wget通过php下载音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过php下载音频文件.我尝试用curl和wget下载它.以下是示例:

I am trying to download audio file over php. I have tried download it with curl and 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");
?>

这篇关于用wget通过php下载音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆