【发布时间】:2017-02-23 21:42:36
【问题描述】:
我正在开发一个从 db 下载歌曲(所以数据类型是 blob)的 android 应用程序。
我有以下下载图片代码示例:
<?php
if($_SERVER['REQUEST_METHOD']=='GET'){
$id = $_GET['id'];
$sql = "select * from images where id = '$id'";
require_once('dbConnect.php');
$r = mysqli_query($con,$sql);
$result = mysqli_fetch_array($r);
header('content-type: image/jpeg');
echo base64_decode($result['image']);
mysqli_close($con);
}else{
echo "Error";
}
如何更改“header”和“echo”(在 header 下)以下载 mp3 音频文件?
【问题讨论】:
-
你说下载歌曲但在你的
header有('content-type: image/jpeg');图像格式对吗? -
搜索“mime type music”会得到stackoverflow.com/q/10688588/1741542
-
是的,image/jpeg 用于图像...所以我需要歌曲...
-
所以按照 Olaf Dietsche 先生的建议更改 mime 类型
-
是的...但是存储歌曲的 db 中的数据类型是 long blob?