i have to save the files from input fields to database,i'll do it this way:
$mkey = mysqli_insert_id($mysqli);
$i=0;
while (isset($_FILES['file'.$i])) {
$filepath = ini_get('upload_tmp_dir')."/".basename($_FILES['file'.$i]['tmp_name']);
$filepath = addslashes($filepath);
$handle = fopen($filepath, "rb");
$content = fread($handle, filesize($filepath));
$stmt = $mysqli->prepare("INSERT INTO attachment (filename,filecontent,mkey) VALUES (?,?,?)");
$stmt->bind_param("sbi",$_FILES['file'.$i]['name'],$content,$mkey);
$stmt->execute();
fclose($handle);
$i++;
}
no error occured,and the other 2 fields mkey and filename are filled in database columns,but the content no,$content shown with print_r in my browser and i sure the $content variable is not empty,but mysql shows me nothing of the content.
RTM ;-)
So I have never done this myself but i would assume it needs to look something like this based on your code and the example on the functions doc page: