i have a web-application for uploading PDF-files into a php-system. I get the selected file with
$filedata = base64_encode(file_get_contents($_FILES['upl_file']['tmp_name']));
and defines the connection so
$dbcon = new PDO("mysql:host=localhost;dbname=signshare", "root", "");
The connection does not fail. Now the problem:
When the uploaded pdf-file is small (like <1mb) everything works fine but when the uploaded file is a little bit bigger (testet with ~3.5mb) the PDO-function failed with no error message. The uploaded file is no insert into the database.
This is my way to upload the file as blob:
$insert_file = $dbcon->prepare(
"UPDATE document SET doc_blob = :blob, `status` = :status WHERE did = :did"
);
$insert_file->bindParam(':blob', $filedata, PDO::PARAM_LOB);
$insert_file->bindParam(':status', $status);
$insert_file->bindParam(':did', $did);
try {
$insert_file->execute();
} catch (Exception $ex) {
$logf = fopen('../controller/log.txt', 'a');
fwrite($logf , "\n BLOB INSERT FAILED: " . $ex . " \n");
fclose($logf);
}
The programm does not throws the exception.
First I had the error-message "Mysql Server has gone away". Then i set max_allowed_packet
to 16M
in the my.ini
file and upload_max_filesize
to 20M
in php.ini
. The error-message gone but the function still not work.
Thank you for help!