MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 16th, 2000, 02:28 PM
CS CS is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 44 CS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
I've noticed a number of questions on the board about storing images in databases. My question is this (hopefully it's a simple one)

Can the actual jpg/gif image be stored as data in the database... or is it just a path to where the image is stored?

If it can be stored as actual data.... how?


Reply With Quote
  #2  
Old June 19th, 2000, 04:31 AM
alexgreg's Avatar
alexgreg alexgreg is offline
Full Access
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jun 2000
Location: London, UK
Posts: 2,019 alexgreg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 15
From what I know about mySQL it is possible to store an image in a database under the BLOB (Binary Large OBject) datetype. However, the maximum size of your picture is limited to 65535 bytes. In order to get your picture into your database I presume you'd do something like this:

<form action=POST enctype=multipart/form-data method=add.php3>
<input type=file name=file>
</form>

---ADD.PHP3---

<?
// Assume already connected to database
insert into table values (
$file
);

?>

That's how to get it in, assuming you have a table called test with one column that is a BLOB datatype: you'll have to use PHP or similar to view the image on a web page, which means that the image tag is going to be something like this:

<img src="recall.php3?name=foo">

which is a bit wierd!

You also might run into problems here if your web host has set a maximum amount of table space that you can use. Whilst 10MB might seem ample for a database containing text, when you start to add pictures it will be used up very quickly! This is another reason why people use the image-copying way of doing it. Personally, when I'm adding records to a database, I'll use PHP to generate a random number, then that random number becomes the image name as well so there's no possibility of the file overwriting another on the server.

------------------------
Alex Greg
(http://www.alex-greg.co.uk)

[This message has been edited by alexgreg (edited June 19, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Stupid image/database question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap