> > > >can you please tell me how to store the images/movie files in the
database
> > > >so that if i click on the image later , i should able to run that
file to
> > > >watch the movie. Is there any way in the cf to do this??
> > > >I'm using sql server7 database with cold fusion 4.5
> > >
> > > I wouldn't store your .mpeg's/.avi's or whatever huge blob's in the
> > > database - just store a path to the file in the database and retrieve
the
> > > file via an url. The performance hit of making SQL Server drag that
huge
> > > file out of the table and across the wire isn't worth it.
> > >
> > > ...Jay
> > >
> >As a matter of fact, only store the name of the file. Set the path to it
in
> >Application.cfm, that way if you have to move the directory structure
around
> >later, no worries...
> >***********************************************
> > Jon Tillman
>
> Good point Jon - storing just the filename allows for the most
flexibility.
Yes, if you don't care about file I/O errors.
To keep files in SQL 7.0
For CF 4.5
This is form
<cfform action="EditUpload.cfm" enctype="multipart/form-data" METHOD=POST>
File to upload <INPUT NAME="FileName" SIZE=50 TYPE=FILE>
<INPUT TYPE=submit>
</cfform>
this is CFM file after submit
<cfoutput>
<CFFILE destination="#path#" action="UPLOAD" nameconflict="MAKEUNIQUE"
filefield="FileName">
<CFIF #File.FileWasSaved# IS "Yes">
<cfset ImageName="#File.ServerFileName#.#File.ServerFileExt#">
<cfset up_file="#GetFileFromPath(form.DocName)#">
<cffile action="ReadBinary" file="#path##ImageName#" variable="UpdateBIN">
<cfset Update64=ToBase64(UpdateBIN)>
<cfquery name="AddUpdate" datasource="#DSN#" username="#user#"
password="#password#">
INSERT INTO Upload
(
up_bin
)
VALUES
(
'#Update64#'
)
</cfquery>
</cfif>
</cfoutput>
For MSACCESS up_bin has data type "MEMO"
For SQL - "binary"
*********************************************************************
retreive :
<cfset NumDoc=0>
<cfset AddN
ame="">
<cfset ErrorHandle=true>
<cfloop condition="ErrorHandle">
<cftry>
<cfquery name="GetDoc" datasource="#DSN#" username="#user#"
password="#password#">
SELECT * FROM Upload
WHERE up_id= #id#
</cfquery>
<cfoutput>
<cfset ShowGif=ToBinary(GetDoc.up_bin)>
<cfif IsBinary(ShowGif)>
<cfif NumDoc is not 0>
<cfset AddName="#NumDoc#">
</cfif>
<cfset FileName="#path#" & "#AddName#" & "#GetDoc.up_file#">
<cfif FileExists("#FileName#")>
<cffile action="Delete" file="#FileName#">
</cfif>
<cffile action="Write" file="#FileName#" output=#ShowGif#>
</cfif>
<script language="JavaScript">
document.location='bin\\#GetDoc.up_file#';
</script>
</cfoutput>
<cfset ErrorHandle=false>
<cfcatch type="Any">
<cfset NumDoc = NumDoc + 1>
<cfset ErrorHandle=true>
</cfcatch>
</cftry>
</cfloop>
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.