TeeJokey Posted June 30, 2009 Share Posted June 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/ Share on other sites More sharing options...
rhodesa Posted June 30, 2009 Share Posted June 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/#findComment-866530 Share on other sites More sharing options...
TeeJokey Posted June 30, 2009 Author Share Posted June 30, 2009 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, Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/#findComment-866551 Share on other sites More sharing options...
rhodesa Posted June 30, 2009 Share Posted June 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/#findComment-866559 Share on other sites More sharing options...
TeeJokey Posted June 30, 2009 Author Share Posted June 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/#findComment-866571 Share on other sites More sharing options...
taquitosensei Posted June 30, 2009 Share Posted June 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/#findComment-866599 Share on other sites More sharing options...
TeeJokey Posted June 30, 2009 Author Share Posted June 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164267-solved-error-uploading-big-files-to-mysql-blob/#findComment-866685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.