WordPress Plugin Development Can’t Upload Image To Database
-
All.
So, I just spent WAY too long trying to fix a problem and I finally did it! Just in case there are others out there trying to do the same thing and can’t find the answer online… well, now… here it is.
I am writing my own custom plugin to be used with WordPress MU 2.9.2.
My plugin allows a ADMIN panel that users can upload an image that will be stored into its own table in MySQL database (under WordPress MU scheme). I have written a matching Widget that will then pull the related images directly from the database and display to website visitors.
The problem I was having was… I could upload images into via my WordPress ADMIN panel screen that were less than approx 60 Kb (kilobytes) in size. Anything over that… just didn’t do anything. It was like I never made the form POST. For the longest time I thought it had to do with my PHP file upload limits (which do need to be set). In the end, it turned out I was using a MySQL database field “BLOB” that is only 64K in size. So, I changed my database field from “BLOB” to “MEDIUMBLOB” and IT WORKED!!! “MEDIUMBLOB” has size of 16MB and “LONGBLOB” has 4GB. Thanks to the following URL I found that on: https://osdir.com/ml/php.database/2002-06/msg00020.html
Also, make sure you have the appropriate settings for the following files:
PHP.ini
; Maximum allowed size for uploaded files. upload_max_filesize = 120M ; Maximum size of POST data that PHP will accept. post_max_size = 100M
MY.ini
key_buffer_size=25M max_allowed_packet=16M
GOOD LUCK and I hope this helps someone else!
- The topic ‘WordPress Plugin Development Can’t Upload Image To Database’ is closed to new replies.