我有一个非常简单直接的问题要做。我需要从我的 MySQL 服务器下载 3 种不同类型的数据:
:图像、音频、视频
所以我正在经历一些深入的 PHP 事情,我发现了这两段代码:
声音的:
<?php
// Connect to database
@mysql_connect("mysql.server.com.br","user","pass01");
@mysql_select_db("database01") or die( "Unable to select database");
// Find out about latest image
$gotten = @mysql_query("SELECT audio_content AS audio_in_blob FROM database01.audio_content WHERE content_id = 'id01';");
if ($row = @mysql_fetch_assoc($gotten)) {
$bytes = $row[ "audio_in_blob" ];
}
else {
echo "hoe!";
$errmsg = 'Could not run query: ' . mysql_error();
$title = "no database image available";
}
// If this is the image request, send out the image
header("Content-type: audio/mp3");
echo $bytes;
exit ();
?>
视频:
<?php
// Connect to database
@mysql_connect("mysql.server.com.br","user","pass01");
@mysql_select_db("database01") or die( "Unable to select database");
// Find out about latest image
$gotten = @mysql_query("SELECT video_content AS video_in_blob FROM database01.video_content WHERE content_id = 'id01';");
if ($row = @mysql_fetch_assoc($gotten)) {
$bytes = $row[ "video_in_blob" ];
}
else {
echo "hoe!";
$errmsg = 'Could not run query: ' . mysql_error();
$title = "no database image available";
}
// If this is the image request, send out the image
header("Content-type: video/mpeg");
echo $bytes;
exit ();
?>
但是这些方法只是在浏览器中显示 blob 而不会下载它们。我能做些什么?我需要下载这些 blob 并使其可用于视频/照片/音频显示。
干杯。