ZEUS ZEUS - 1 year ago 74
Android Question

Issue in php with "header"

I am developing an android app that download songs(so type of data is blob) from db.

I have the following download image code example:


$id = $_GET['id'];
$sql = "select * from images where id = '$id'";

$r = mysqli_query($con,$sql);

$result = mysqli_fetch_array($r);

header('content-type: image/jpeg');

echo base64_decode($result['image']);


echo "Error";

How do I change "header" and "echo"(under header) to download an mp3 audio file ?

Answer Source

You'll want to send the following header for a .mp3 file:

Content-Type: audio/mpeg3

Refer to https://www.sitepoint.com/web-foundations/mime-types-complete-list/ for a good list of MIME types.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download