I am developing a PHP script for uploading .PDF documents as medium BLOBs into a MySQL database via PHP. The script also allows users to search for files and open/download
YOu might be running up against the limitations of the HTTP request (which I think is 4MB), or your HTTP request might be timming out. I have run into this issue before. You might want to look @ your php.ini file for maximum upload size.
Disclaimer: I am not a PHP developer :D
I actually fixed the issue. I changed all of the values that were recommended here in php.ini and my.cnf but I also needed to change a setting for PDO.
I changed: PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer) Maximum buffer size. Defaults to 1 MiB.
This has to be set when the PDO object is created to work though. All is good now.
You might be running into a mySQL limit.
Run the following in mySQL:
show variables like 'max_allowed_packet'
That will show you your current setting. The default is 1047552 bytes.
This can be changed with your my.cnf file. Simply add
set-variable = max_allowed_packet=2M
or what ever size is required and restart mySQL.
EDIT:
What about
<input type="hidden" name="MAX_FILE_SIZE" value="xxx" />
Might that be part of the problem?
So to recap all the things I believe I had to set in order to allow file uploads >1MB on something I was working on:
post_max_size
(I wanted 15MB file uploads, so I set it to 20M
just in case)upload_max_filesize
to 15M
max_execution_time
at 60
max_input_time
at 60
default_socket_timeout
at 60
max_allowed_packet
to 15M
changed my PDO call to:
new PDO("mysql:host=$host;dbname=$db_name", $db_username, $db_password, array (PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>15*1024*1024))
If you're trying to do this on shared hosting (where you can't make changes to MySQL conf files, etc), Google 'mysqli prepared statements'.
This allows you to upload large queries in predefined byte chunks, circumventing any buffer restrictions.