473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Storing images in mySQL

Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the
picture on a webpage.

Any help would be appreciated.
Jul 19 '05 #1
9 17036
Put the binary raw content of the image in a BLOB (or MEDIUMBLOB) field.
Then do a select to get the content of that field. Put that content in a
temporary file with a random filename. In the PHP page, make a reference to
this temporary image by outputting the HTML.

<img src="<?php echo $temporary_filename; ?>">

I think there are more fancy ways of doing this, but that should be working.

Good luck

Vincent Bouret

"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #2
Put the binary raw content of the image in a BLOB (or MEDIUMBLOB) field.
Then do a select to get the content of that field. Put that content in a
temporary file with a random filename. In the PHP page, make a reference to
this temporary image by outputting the HTML.

<img src="<?php echo $temporary_filename; ?>">

I think there are more fancy ways of doing this, but that should be working.

Good luck

Vincent Bouret

"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #3
Put the binary raw content of the image in a BLOB (or MEDIUMBLOB) field.
Then do a select to get the content of that field. Put that content in a
temporary file with a random filename. In the PHP page, make a reference to
this temporary image by outputting the HTML.

<img src="<?php echo $temporary_filename; ?>">

I think there are more fancy ways of doing this, but that should be working.

Good luck

Vincent Bouret

"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #4
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #5
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #6
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw. ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display the picture on a webpage.

Any help would be appreciated.

Jul 19 '05 #7
I read that tutorial - I'm only getting the filename stored in the
table, not the actual image -

$php_SQL = "UPDATE photos SET photo1 = '".$php_image."'"." WHERE
member_name = '".$php_member_name)."'";

Is this correct or am I missing something???

Raph

On Sun, 17 Aug 2003 17:04:11 GMT, "Jamie Davison" <ja***@bardavon.org>
wrote:
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw .ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display

the
picture on a webpage.

Any help would be appreciated.


Jul 19 '05 #8
I read that tutorial - I'm only getting the filename stored in the
table, not the actual image -

$php_SQL = "UPDATE photos SET photo1 = '".$php_image."'"." WHERE
member_name = '".$php_member_name)."'";

Is this correct or am I missing something???

Raph

On Sun, 17 Aug 2003 17:04:11 GMT, "Jamie Davison" <ja***@bardavon.org>
wrote:
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw .ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display

the
picture on a webpage.

Any help would be appreciated.


Jul 19 '05 #9
I read that tutorial - I'm only getting the filename stored in the
table, not the actual image -

$php_SQL = "UPDATE photos SET photo1 = '".$php_image."'"." WHERE
member_name = '".$php_member_name)."'";

Is this correct or am I missing something???

Raph

On Sun, 17 Aug 2003 17:04:11 GMT, "Jamie Davison" <ja***@bardavon.org>
wrote:
There's a good tutorial at: http://codewalkers.com/tutorials/35/1.html

-JD
"Ash Christopher" <as************@newthink.net> wrote in message
news:UI***********************@news1.calgary.shaw .ca...
Is there a way to store images in a mySQL database? I was hoping to store
them in a table, then use php to call them from the database and display

the
picture on a webpage.

Any help would be appreciated.


Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: Eben Goodman | last post by:
I am storing book isbn numbers in a table. isbn numbers are 10 digit numbers and many start with 0. The data type of the field I am storing this info in is a bigint(16) unsigned. It appears that...
0
by: Ash Christopher | last post by:
Is there a way to store images in a mySQL database? I was hoping to store them in a table, then use php to call them from the database and display the picture on a webpage. Any help would be...
7
by: Benoit St-Jean | last post by:
I am looking at options/ways to store 12 million gif/jpg images in a database. Either we store a link to the file or we store the image itself in the database. Images will range from 4k to 35k in...
6
by: bissatch | last post by:
Hi, I am currently writing a news admin system. I would like to add the ability to add images to each article. What I have always done in the past is uploaded (using a form) the image to a...
2
by: bissatch | last post by:
Hi, I am trying to write script that is run when a form is submitted. The form contains an image input field and when submitted, the image is uploaded, resized and added as binary information to...
4
by: Rednelle | last post by:
Greetings all, As a newbie, using Access 2000, I would appreciate advice on the best way to include pictures. I have developed a 'Home Inventory' database which can include jpeg thumbnails of...
1
by: steelghost | last post by:
I'm currently trying to store images into my DB. But the collation used on my DB is big5, since my client wants this default encoding on their webpage. So to be able read the retreived data I have...
3
by: Lucky_Syringe | last post by:
I wrote this script to display different files from a database and properly display them by their respective MIME types. I have two questions: the first is that it just so happens not to work, and...
2
by: ghjk | last post by:
I want to develop web site for vehicle sale. There I want to store vehicle images. I'm planing to use mysql DB. Please tell me is it possible to user mysql db for that kind of data storage?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.