LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-21-2018, 07:34 AM   #1
fred2014
Member
 
Registered: Mar 2015
Posts: 64

Rep: Reputation: Disabled
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)

TIA
 
Old 09-21-2018, 11:19 AM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,344

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
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.

Last edited by scasey; 09-21-2018 at 11:22 AM.
 
1 members found this post helpful.
Old 09-21-2018, 05:34 PM   #3
fred2014
Member
 
Registered: Mar 2015
Posts: 64

Original Poster
Rep: Reputation: Disabled
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.
 
Old 09-22-2018, 03:04 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,381
Blog Entries: 9

Rep: Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651Reputation: 3651
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?
 
Old 09-23-2018, 05:13 AM   #5
fred2014
Member
 
Registered: Mar 2015
Posts: 64

Original Poster
Rep: Reputation: Disabled
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?
 
Old 09-24-2018, 12:34 PM   #6
Janvanl
Member
 
Registered: Apr 2015
Posts: 84

Rep: Reputation: Disabled
maybe here you can find an answer

https://lists.mysql.com/mysql/137589

regards,
Jan
 
Old 09-24-2018, 04:50 PM   #7
fred2014
Member
 
Registered: Mar 2015
Posts: 64

Original Poster
Rep: Reputation: Disabled
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.
 
Old 09-24-2018, 04:58 PM   #8
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,344

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
"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.
 
Old 09-24-2018, 04:59 PM   #9
Janvanl
Member
 
Registered: Apr 2015
Posts: 84

Rep: Reputation: Disabled
Have you checked the versions of PHP / Mysql?

PHP 7 should be faster.

Do you use FPM?

regards,
Jan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using the images directory in HTML. oozypal Linux - Server 1 07-15-2008 02:27 PM
MySQL results to html forms using PHP xemous Programming 3 08-15-2005 04:27 PM
html, xml, php, mysql atheist Programming 8 06-07-2004 02:28 PM
PHP and MySQL (Images) Jayantha Linux - Newbie 1 05-20-2004 04:45 AM
HTML, PHP, MySQL sets Robert0380 Programming 5 09-03-2003 06:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration