I have a form and I’m trying to upload a image into mediumblob field in mysql.
I have five field…id, title, text, data, image.
All the field used method $_POST
All fields are ok except ‘image’.
if i upload the image used phpmyadmin evrything is OK. The medium blob field is full.
if I upload the image whit the form evrything is wrong. The medium blob field is empty --there is no image.
BUT. I can’t imagine that will work without somehow encoding the binary image data. I’ve read about using addslashes() after loading the image contents, but I’m sure someone else can comment on whether that’s still a current way to do things.
Another approach suggested in an older thread on here is to modify the query:
Why are you storing the image in the database table?
I save the file into a files directory and store the filename in the table. Much cleaner and easier.
That article I linked to earlier on also talked about the good and bad points of doing that. Of course, storing the image in the table means that, as long as you backup the table, you don’t lose any images in the event of a system problem. Of course, having a proper backup strategy that also backs up the uploaded images folder also solves that issue. The down-side, of course, is having much larger database tables.