-   Linux - Software (
-   -   Problem with images using mysql php and html (

fred2014 09-21-2018 06:34 AM

Problem with images using mysql php and html
I'm having an issue getting a mysql (InnoDB) medium blob to display it's image on the HTML page.

Everything works correctly if an an image below 1MB is used.
Anything larger generates an incomplete base64 transmission
of the image and hence an empty box on the page.

This is a known issue according to yahoo searches an I have
implemented everything I can find - 2 lines to add to the
my.ini file to increase packet allotment.

However this has not corrected the problem on my system.
ob_start - end options have been tried as have mysql_flush variations.
Uploads are set to 20MB so a 2MB image shouldn't have trouble but it does.

There must be something configured somewhere that is affecting this
perhaps in php mysql Apache or other ini/cnf but I can't find anything after going through it all.

Does anyone have any hard information of the specific variables
in these .ini/conf files that may be affecting packet sizes or the ability to send a 2MB base64 encoded file from a mysql blob to a html page via php - perhaps there is a cache somewhere that isn't obvious?

I'd really like to get the cause for this nailed down not just
"randomly fixed"

(the code itself clearly works as all smaller imaged transfer fine)


scasey 09-21-2018 10:19 AM

I realize this is not a specific answer to your question.

I manage what you're doing by storing the images outside the database and storing only the location in the database. The db contains descriptions, names of people in the picture, date (it's a Family Photo Album application) and is searchable...but displaying the image is done by writing the location into the img tag and letting the browser pull the image from the filesystem.

Just a thought.

fred2014 09-21-2018 04:34 PM

Thanks scasey

I dont think that would work - at least not with the rest of my system.
It needs to integrate a number of modules that dont work that way.

I have done it a similar way myself in the past but not this time.

ondoho 09-22-2018 02:04 AM

base64 - you mean the image gets encoded as text straight into the web page?
not directly answering your question, but this doesn't strike me as a good idea for images larger than a few kilobytes.
imagine the amount of text +1MB would generate, and there's multiple such images in one page?

fred2014 09-23-2018 04:13 AM

Sorry - I didnt know there was any other way than base64 to transfer from
an sql database to a HTML page (using php of course).

How would you do this?

Janvanl 09-24-2018 11:34 AM

maybe here you can find an answer


fred2014 09-24-2018 03:50 PM

Thanks jan but this isn't specifically a mySQL issue.
Putting the file into mysql works fine.
I expect your were refering to the response for packet adjustment
but as mentioned in my original I've already done that.

I'm guessing it's a transport or cache issue between mySQL and PHP
or PHP to HTML Apache server - I can't so far identify what however.

Most people have reported increasing that packet-size has solved their
problem - for some reason that isn't working on my system.

scasey 09-24-2018 03:58 PM

"is it plugged in" questions:

After updating the packet-size, did you restart mysql and httpd? And, yes, did you clear your browser cache?

No offense intended. Sometimes folks forget to do that.

Janvanl 09-24-2018 03:59 PM

Have you checked the versions of PHP / Mysql?

PHP 7 should be faster.

Do you use FPM?


All times are GMT -5. The time now is 04:16 PM.