Jump to content

Recommended Posts

Hi all,

 

I want to upload images to a table in mysql with a BLOB column.

 

If the file is not much big, like 1MB or lower, no problem, but i have many images bigger, up to 16MB. I have already modified the max_allowed_packet variable in mysql, but it still shows the same error: MySQL server has gone away.

 

I have gone through many forums and googled for hours and i couldn't find anything that could solve the problem.

 

Could anybody throw some light over this issue?

 

Best regards.

My suggestion is to not use BLOBs. Just keep them as files in a folder. You can still have a record in a table to track info about the image, but for images (big ones especially), you will find it better to keep them as files.

Thanks for your reply rhodesa.

 

Many people have given me that advice already, and we are already working that way. But i want to try at least to see if it's more suitable for us to have them in database, cause it's quite messy in file system and there is always the risk of filename missmatch.

 

I appreciate your advice but doesn't solve the problem (at least until we try how all goes without using file system).

 

I forgot to say that it's Windows 2003 server, PHP 5.2.5 is running under IIS and it's MySQL 5.

 

Best Regards,

the way you get around filename mismatch, is when the file is uploaded, create a row in the table with the info about it:

  -Unique ID from an auto increment

  -Filename

  -Content Type

 

Then, move the uploaded file to the folder where all the files are, renaming it to the unique id from the table row. This way every file has a unique file name.

Thanks again rhodesa,

 

I'm sure that will help with storing them in file system but i still want to try storing everything in database and then i'll decide which way fits us better.

 

I still didn't solve the problem with big size files.

 

Best Regards.

I found this under BLOB's description on the MySQL site.

 

The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size by changing the value of the max_allowed_packet  variable, but you must do so for both the server and your client program.

Well, the fact is that somehow the max_allowed_size was not properly set at server, i did again, this time using the MySQL Administrator, that interface for configuring MySQL on windows and now it works perfectly.

 

Thanks all for your posts in this thread.

 

Best Regards.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.