![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
New Coder ![]() Join Date: Oct 2004
Posts: 64
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
Uploading Larger Files into database
I have written a file upload script that allows the user to upload files using a web form, and the file is saved into this database:
table myfiles: id int(11) PRI auto_increment file_title varchar(255) file_type varchar(255) file longblob submittedby varchar(20) Here is my script: PHP Code:
I'm getting this error: 1153: Got a packet bigger than 'max_allowed_packet', but only with files over 1MB in size. Is there a way to change this max_allowed packet to allow for larger files? If so how? Thanks in advance, Melissa Last edited by melissa820; 04-07-2005 at 09:42 PM.. |
|
|
|
|
|
PM User | #2 | ||
|
Regular Coder ![]() Join Date: Mar 2005
Location: Moscow, Russia
Posts: 207
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
Code:
/* You must increase this value if you are using big BLOB columns or long strings. It should be as big as the biggest BLOB you want to use. The protocol limit for max_allowed_packet is 16MB before MySQL 4.0 and 1GB thereafter. */ -- set to 16 MB SET @@max_allowed_packed=16777216; -- or SET @@session.max_allowed_packed=16777216; Quote:
|
||
|
|
|
|
|
PM User | #3 | |
|
New Coder ![]() Join Date: Oct 2004
Posts: 64
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
Quote:
But how exactly do I do this? Can I send it through mysql_query like below? mysql_query("SET @@max_allowed_packed=16777216", $link) I don't have permission to modify any .ini files. I'm using MySQL version 4.0.20. PHP4 I think. Last edited by melissa820; 04-06-2005 at 10:37 PM.. |
|
|
|
|
|
|
PM User | #4 | |
|
Regular Coder ![]() Join Date: Mar 2005
Location: Moscow, Russia
Posts: 207
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
|
|
|
|
|
|
|
PM User | #5 |
|
New Coder ![]() Join Date: Oct 2004
Posts: 64
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
Thanks. Do I have to set this every time I open a connection? Or do I just set it once and it will stay like that forever?
Never mind, I read about the global vs. session. I don't have access to the global variable. So I figure I can just sent the SET command right before I try to do the INSERT. Last edited by melissa820; 04-07-2005 at 04:22 PM.. Reason: I answered my own question. |
|
|
|
|
|
PM User | #6 |
|
New Coder ![]() Join Date: Oct 2004
Posts: 64
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
This doesn't seem to be working. Or rather, it doesn't solve my problem. I set the max_allowed_packet to 16777216, and verified that it worked by doing "SELECT @@max_allowed_packet". But I still get that same error message when trying to insert the file: Got a packet bigger than max_allowed_packet.
Now, the max_allowed_packet size is = 16777216. The size of the file I'm uploading is = 1092946. So how can it have gotten a packet that is too big?? Here's my updated code: PHP Code:
|
|
|
|
|
|
PM User | #7 |
|
New Coder ![]() Join Date: Oct 2004
Posts: 64
Thanks: 2
Thanked 0 Times in 0 Posts
![]() |
OK I devised a bit of a work-around for this problem. If anyone else is interested, here it is below.
PHP Code:
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|