donglu4159 2011-02-06 01:00
浏览 204
已采纳

如何获取和播放存储为MySQL BLOB的WAV文件?

I want to get and play the WAV file stored in MySql Db using PHP and Zend-Framework. But I am not able to do so. I want to do this in 2 steps: 1. Convert the BLOB as .wav file 2. Play that .wav file in a new window.

Please help me............

Thanks in advance......

  • 写回答

2条回答 默认 最新

  • dongxie559554 2011-02-06 01:08
    关注

    To store the data in the database, you would do something like this:

    $tmpName  = $_FILES['userfile']['tmp_name'];
    
    $fp      = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);
    

    And then you would insert $content into the blob field in the sql query. To read the files, it would be something like:

    $query = "SELECT name, type, size, content " .
         "FROM upload WHERE id = '$id'";
    
    header("Content-length: $size");
    header("Content-type: $type");
    header("Content-Disposition: attachment; filename=$name");
    echo $content;
    

    To read the file, just have the 2nd code executed and the file should download. You can point your flash player or what ever you use to the url with the above code, and it should work.

    Hope this helped REF: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料