我在将数据库写入blob(音乐文件)时遇到了问题。当我尝试和上传说歌曲(“没有其他Matter.mp3”)它播放一些其他(我试图上传一些时间像songB(“甜的孩子mine.mp3”)...并且它不完全关闭一个)当然,歌曲到服务器是正确的(我已经检查过)通过播放文件我打印['tmp_name']。Mysql插入到Blob问题
我用这上传
$contenttype = $_FILES['song']['type'];
$songfile = $_FILES['song']['tmp_name'];
$size = $_FILES['song']['size'];
$query = "INSERT INTO file(contenttype,file,size) values('".$contenttype."',LOAD_FILE('$songfile'),".$size.")";
这是我的DBTABLE文件
CREATE TABLE file(
id INT PRIMARY KEY AUTO_INCREMENT
,contenttype VARCHAR(30)
,file LONGBLOB
,name VARCHAR(30)
,size INT
)engine=innodb;
的结构,因为服务器获得正确的文件,我认为故障是与MySQL
通过
下载文件$query = "SELECT * FROM file WHERE id=$fileid";
$res = mysql_query($query,$connection) or die("$fileid Error ".mysql_error());
if(!$res){
$status = false;
error_log("fileid: ".$fileid);
$response = new Tonic\Response(Tonic\Response::OK); //using tonic shouldn't matter
}else{
$tres = mysql_fetch_assoc($res);
$response = new Tonic\Response(Tonic\Response::OK);
$response->contentType=$tres['contenttype'];
$response->contentLength=$tres['size'];
$response->contentTransferEncoding='binary';
error_log('Length: '.strlen($tres['file'])); //strangely this is zero ?? but how is it even playing ??
$response->body = $tres['file'];
}
*编辑我已经下了数据库几次,会导致任何问题?
你是如何得到文件退出? – deceze 2013-05-14 05:32:32
$ songfile的值是多少? – 2013-05-14 05:34:30
@Devin Crossman更好奇它来自哪里)) – BlitZ 2013-05-14 05:35:07