473,407 Members | 2,676 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,407 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 17038
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.