one simple solution for this. Why u want to store image in database. u can upload the image in the server. and just stored path of image in database.
so in the database it will stored as ../../photofiles/test.jpg for examples.
and actual image will be in the photofiles folder of ur application.
Main Topics
Browse All Topics





by: anandkpPosted on 2003-04-18 at 22:43:00ID: 8357656
<!--- ========================== ========== ========== ========== ========== ========== ========== ========== ========== --->
ta">
h(GetCurre ntTemplate Path())#/t mp.jpg" output="#toBinary(getImg.P HOTO)#" addnewline="No"> h(GetCurre ntTemplate Path())#/t mp.jpg" deletefile="Yes">
========== ========== ========== ========== ========== ========== ========== ========== --->
<!--- the form page - test.cfm --->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<BODY>
<FORM name="test" method="post" action="test_action.cfm" enctype="multipart/form-da
<INPUT type="File" name="myFile">
<INPUT type="Submit">
</FORM>
</BODY>
</HTML>
/*
This file takes the file selected in the previous template, and inserts it into the database.
(Need to insert a DSN, username/password ;-)
*/
<!--- the insert page test_action.cfm --->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<BODY>
<CFFILE ACTION="ReadBinary" FILE="#MyFile#" VARIABLE="aBinaryObj">
<CFIF isBinary(aBinaryObj)>
<CFSET base64 = toBase64(aBinaryObj)>
<CFELSE>
<CFABORT showerror="The file doesnt seem to be a binary file">
</CFIF>
<CFQUERY datasource="" username="" password="">
INSERT INTO PHOTOS(PERSON_ID, PHOTO)
VALUES (1,<CFQUERYPARAM VALUE="#base64#" CFSQLType="CF_SQL_CLOB">)
</CFQUERY>
</BODY>
</HTML>
/*
This file pulls the image from the database, and then moves to result.cfm, which is where the image "appears"
(Again, supply DSN username/password)
*/
<!--- the Select doc page --->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
</HEAD>
<BODY>
<CFQUERY name="getImg" datasource="" username="" password="">
SELECT PHOTO FROM PHOTOS WHERE PERSON_ID = 1
</CFQUERY>
<CFFILE action="WRITE" file="#GetDirectoryFromPat
<CFLOCATION url="result.cfm">
</BODY>
</HTML>
/*
This is the image from the database!
*/
<CFCONTENT type="image/jpeg" file="#GetDirectoryFromPat
<!--- ==========================