Post  picture to keep in database.

Posted on 2003-02-19
Medium Priority
Last Modified: 2013-12-24
hi experts,

i'm very new in creating a web page using coldfusion(to link to database) and dreamweaver( as the interface). i need to do one function that can let the user to post their picture through the web page and keep in the database.can tell me how to do it?Please help!!!
Question by:ysloo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 17

Accepted Solution

anandkp earned 120 total points
ID: 7985718
hi this is easy,

allow the user to upload the picture to a particular dir - say "root/userimages/myphoto.jpg"

now just insert teh value [as text] "myphoto.jpg" in the DB

when referring to the image for this particular user ... call the record from the DB - using his userid & read the column that stores teh imagename

displayt eh image as http://urdomain.com/userimages/#query.Imagecolumn#

let me know


Assisted Solution

TallerMike earned 120 total points
ID: 7987698
I agree with anand, storing the picture in the DB itself is NOT the best method. Saving it on the server is probably going to be easier, then you just store the location on the server of the image and output it as he said.


When you store an image in the DB, it's in a BLOB type field. The trick to this isn't storing the image, it's retrieving it in a usable fashion. What you'd need to do is to have a call like so:

<img src="userImage.cfm?imageID=8675309" />

Then on userImage.cfm:

<cfquery name="qImage" datasource="Jenny">
  SELECT imageObj
  FROM imageTable
  WHERE imageID = #url.imageID#

From here, there's 2 places you can then go. Either way, you'll use CFCONTENT to setup the correct MIME type (image/gif or something like that) for the download.

One method is to simply output the imageObj like so:

<cfcontent type="image/gif">

But the preferred method is to write the image to a file on the web server, and THEN cal CFCONTENT with the path of the image like so:

<cfcontent type="image/gif" deleteFile="Yes" file="#fileLocation#">

Where fileLocation is the full URL of where you wrote the image file from the DB.


So what's to learn from this? Well, in the end (in the preferred method), you ended up writing the image to the disk anyhow, so it may as well have already been there. It would have been faster and more stable.

Author Comment

ID: 7996943
hi experts,
thanks for helping me!
however i not really get what u guys mean.i'm really slow in learning these thing.what i understand now is not storing pictures in DB.
is that i need to create a folder in my web server to write the images?do i still need to create a DB(table) for pictures/images?
please help!thanks again!

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

LVL 17

Expert Comment

ID: 8006395
yes - ur getting it right

create a folder called userimages on server & save all the images that the user wld upload in there

also have a DB-table where u can insert records of users - but just store the image name in there - so its easier for u to read/write

follow the instructions in my first comment & that shld be it

LVL 17

Expert Comment

ID: 10161540
hello ??????????
LVL 35

Expert Comment

ID: 10930998
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation in the Cleanup topic area:

Split anandkp & TallerMike

Please leave any comments here within the next four days.

EE Cleanup Volunteer

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question