I'm currently developping a PHP website and I need to store files in my database.
I'm using a LONGBLOB to store files such as PDF,PPTX,...
The file upload was working fine until i get this error :
Fatal error: Allowed memory size of 134217728 bytes exhausted
Here is my function :
public function uploadFile() {
// We upload only pdf for now
if (isset($_FILES['fichier']['name']) && $_FILES['fichier']['type']=="application/pdf"){
$tmp_name = $_FILES['fichier']['tmp_name'];
// Avoid problem with space
$nom = str_replace(' ','_',$_FILES['fichier']['name']);
$taille = $_FILES['fichier']['size'];
$type = $_FILES['fichier']['type'];
$fp = fopen($tmp_name, 'rb');
$content = fread($fp, filesize($tmp_name));
$statement = $this->db->prepare("INSERT INTO document(nomfichier,fichier,typefichier,taillefichier) VALUES (?,?,?,?)");
$statement->bindParam(1, $nom);
$statement->bindParam(2, $content, PDO::PARAM_LOB, $taille);
$statement->bindParam(3, $type);
$statement->bindParam(4, $taille);
$statement->execute();
$statement->closeCursor();
// Redirect
header('Location: documentation');
die('redirect');
Edit : Problem comes from the database who choose a blob instead of longblob when regenerated