How to store Images in Database

Volkof

Well-Known Member
Reaction score
31
Hi all,

I will be needing this as users will be uploading their profile pics.
Basically, how do database store "images". I dont believe there is a "image" datatype in mySQL. How is Facebook able to store pictures?

Some of my friends say to convert images into bits (1s and 0s), but that would be lengthy.
Some websites ask users to upload images to another website, then copy the url and paste, like :
https://www.yousendit.com
http://imageshack.us/

Any form of advice would be appreciated.
Thank you
 

DrEvil

FCRI Associate!
Reaction score
111
I think that once the file has been selected from the window, the images are stored in a sub folder on the server(hence why it takes some time to upload an image as the whole image needs to be 'copied' onto the server (with upload speeds being lower than downloads))

e.g. root/images/filenumber53464.png
when you make a post a variable would be set in the post table(in the database) to show an image as an attachment (with id as the one saved 'filenumber53464.png')
 

Volkof

Well-Known Member
Reaction score
31
You mean once the img is uploaded to server, the database stores the path name as String?
 

DrEvil

FCRI Associate!
Reaction score
111
I think that is what happens, it seems most logical as you cannot save all the 'data' on an image file and then recreate an image on the spot in a webpage.
Maybe someone could correct me if anything I said wasn't accurate. :cool:
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Save it as a blob.
Although the preferred way is to save it on disk and then link to that in your db.
 

Volkof

Well-Known Member
Reaction score
31
@Magentix

blob is Binary Large Object right? How does it work?
 

The Helper

Necromancy Power over 9000
Staff member
Reaction score
1,688
I never store images in a database I only store paths to them on the server and do a naming convention for them. Basically the images are stored on a drive in a folder however you want.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top