mike yang wrote:
i’m sure some of you had come across this problem before, but i was
unable to find the answer after spending quite some time searching.
i have a basic file uploader, code similar to rails recipe (or rails
problem occurs when i try to upload files (images) greater than 500KB.
the largest file i could upload was 493KB and i’ve uploaded a bunch
files under 490KB and they all worked. the smallest file which i failed
to upload is 500KB so i guess that’s where the “limit” is.
my data field in mysql is set to mediumblob, inevitably, i tried
changing it to longblob which didn’t work.
i’m running the webrick server.
Any help would be greatly appreciated…
I am aware that this post is quite old. But I went through the same
scenario as you have described above by testing different file sizes
around 500KB. The only relevant search result I found was this thread
with no replies. The error from rails was ActiveRecord::StatementInvalid
and not much more info to go on besides the fact that the error was
thrown in the MySQL adapter. After looking in my development.log I could
actually read the error message that the MySQL server had returned. The
problem was that the MySQL server by default did not allow incoming
packets to be larger than 500KB. The solution is to change the
“max_allowed_packet” variable in your MySQL server. Which is described
on this link:
I simply created (on FreeBSD) a /etc/my.cnf and added the following two
lines and then restarted MySQL:
A tried to upload a file ~14 MB and I got the same error as before. Make
sure you have this variable set with a marginal.
Hope that helped