473,395 Members | 1,466 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,395 software developers and data experts.

Writing Images to MySQL 4.x

Hi,
I have been trying to write an image to a database table BLOB field in
MySQL but when I try to retrieve the image to display it, it shows as
being empty. Are there any special considerations I need to take into
account when reading and writing images to a DB? Thanks.

Sep 12 '06 #1
4 1645
jackpod wrote:
Hi,
I have been trying to write an image to a database table BLOB field in
MySQL but when I try to retrieve the image to display it, it shows as
being empty. Are there any special considerations I need to take into
account when reading and writing images to a DB? Thanks.
Writing images into database is not good idea expect if the images are very
small. Better is to create some upload directory and save images here. Into
database you write the (generated) filenames only. The procedure is some
like this:

IF file is attached (uploaded)
genetare new unique filename
get file extension from original filename
save attached file into upload directory as
generated_filename.original_extension
put new filename into some table
ENDIF

And procedure for viewing in browser is like this

IF ! EMPTY(filename in table)
echo "<img src=\"upload_directory/$filename\">";
ENDIF

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Sep 12 '06 #2
jackpod wrote:
Hi,
I have been trying to write an image to a database table BLOB field in
MySQL but when I try to retrieve the image to display it, it shows as
being empty. Are there any special considerations I need to take into
account when reading and writing images to a DB? Thanks.
There shouldn't be a problem with storing it in the database and
retrieving it later. Can you post the code you're using so we can take
a look at it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 12 '06 #3
On 12 Sep 2006 06:31:44 -0700, "jackpod" <jo*******@gmail.comwrote:
I have been trying to write an image to a database table BLOB field in
MySQL but when I try to retrieve the image to display it, it shows as
being empty. Are there any special considerations I need to take into
account when reading and writing images to a DB? Thanks.
One thing to consider is that BLOB only stores up to 64kB, which may not be
big enough. But as Jerry says, you should post some code.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 12 '06 #4
Thanks all for your replies. I have been able to read and write images
to the db successfully. I ended up using longblob type and things
worked ok. thanks.
Andy Hassall wrote:
On 12 Sep 2006 06:31:44 -0700, "jackpod" <jo*******@gmail.comwrote:
I have been trying to write an image to a database table BLOB field in
MySQL but when I try to retrieve the image to display it, it shows as
being empty. Are there any special considerations I need to take into
account when reading and writing images to a DB? Thanks.

One thing to consider is that BLOB only stores up to 64kB, which may not be
big enough. But as Jerry says, you should post some code.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 13 '06 #5

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

Similar topics

1
by: A | last post by:
Hi everyone I was working on a php script to display images and I am running into problems. My problems are when I execute the query to thumb path it won't display the image/s. Anyhelp is...
3
by: Srdjan Pejic | last post by:
Hello, I have a problem that I have not been able to solve, even after searching the web. I have stored couple of images in the MySQL database and I am trying to get them displayed on a web page...
0
by: Jonas Meurer | last post by:
hello, i develop a project with a mysql interface. one mysql table holds all the images for my project. everything works quite well so far, except i'm not able to upload images into the...
0
by: Dan Anderson | last post by:
Can anyone point me to a reference on how to insert images into a column in a mySQL database -- or is that not possible? Thanks in advance, Dan Anderson -- MySQL General Mailing List
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...
10
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without...
1
by: ttamilvanan81 | last post by:
Hai everyone, I need to provide the slideshow for the images. I have upload the images into database. Then i will retrive all the images from the database and provide the slideshow for those...
4
by: Jordan79 | last post by:
I have code written to generate xml data in PHP from my MySQL database. I can display this in my browser using "echo" but wbat I really want is to write this xml data to a seperate xml file so that...
6
by: Keith Hughitt | last post by:
Hi all, I've run into a strange error while trying to store some PNG images in a MySQL database using MySQLdb. When I try to insert smaller images (< 64kb or so) everything seems to work fine....
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.