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
RTM ;-)
If data size of a variable exceeds max. allowed packet size (max_allowed_packet), you have to specify b in types and use mysqli_stmt_send_long_data() to send the data in packets.
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:
$filepath = ini_get('upload_tmp_dir')."/".basename($_FILES['file'.$i]['tmp_name']);
$filepath = addslashes($filepath);
$handle = fopen($filepath, "rb");
$content = null;
$stmt = $mysqli->prepare("INSERT INTO attachment (filename,filecontent,mkey) VALUES (?,?,?)");
$stmt->bind_param("sbi",$_FILES['file'.$i]['name'], $content, $mkey);
while (!feof($handle)) {
// $maxPacketSize would be the size of your max packet setting for mysql,
// or something safely assumed to be below it
$stmt->send_long_data(1, fread($handle, $maxPacketSize));
}
fclose($handle);
$stmt->execute();