php - Mysql Insert Into Blob problems -


this question has answer here:

i have problem when comes write blob (a music file) on database. when try , upload songa("nothing else matter.mp3") plays other (the 1 tried upload time earlier songb("sweet child of mine.mp3")... , not off one) of course song goes server right ( have checked ) playing file printing ['tmp_name'].

i using upload

$contenttype = $_files['song']['type']; $songfile = $_files['song']['tmp_name']; $size = $_files['song']['size']; $query = "insert file(contenttype,file,size) values('".$contenttype."',load_file('$songfile'),".$size.")"; 

this structure of dbtable file

create table file(      id int primary key auto_increment     ,contenttype varchar(30)     ,file longblob     ,name varchar(30)     ,size int )engine=innodb; 

since server getting right file, assumed fault mysql

file download through

$query = "select * file 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 0 ?? how playing ??     $response->body = $tres['file']; } 

*edit have droped database several times, cause problems ?

load_file

your problem writing music file blob. $songfile has path file on server


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -