can't upload a .pdf file larger than 1 mb ----(ERROR::mysql server has gone away)

mysql, php

Solution

I believe you also have to configure the MySQL server (my.ini on Windows) make sure there is:

[mysqld]
    max_allowed_packet=16M

in there - or any sufficiently high number

also note the same problem solved here: how to change max allowed packet size

Problem

i have written a php code to upload .pdf file into my datbase. the code is working perfect for all pdfs which are less than 1 mb in size.but whenever i am trying to upload a file larger than 1 mb in size , it's failing to upload and throwing a error mysql server has gone away. NOTE:: i have changed my php.ini with following changes ``` post_max_size=128M upload_max_filesize=128M memory_limit = 128M max_execution_time = 300 max_input_time = 300 ``` but it's not solving my problem.the problem remains same "it's failing to upload and throwing a error mysql server has gone away." MY PHP CODE IS :: ``` if(isset( $_POST['save']) and $_POST['save'] == "save") { ini_set('default_socket_timeout', 1500); include_once $_SERVER['DOCUMENT_ROOT'].'/include/db.inc.php' ; if (!is_uploaded_file($_FILES['upload']['tmp_name'])) { echo 'There was no file uploaded!'; exit(); } /*NOW I HAVE WRITTEN THE PHP CODE TO INSERT THE FILE INTO MY DATABASE.WHAT I CAN ASSURE YOU THIS PART IS PERFECT BECAUSE THE CODE IS SUCESSFUL ALL OTHER CASES WHICH ARE LESS THAN 1 MB IN SIZE*/ ``` NOTE:: i also used a reconnect while sending the query.so there is not a connection problem EDIT there is nothing like `max_allowed_packet` in my my.ini

Original source

Related problems