The action page:

<cfobject type="component" name="cms_component" component="raw_cms">

<cfinvoke 
 component="#cms_component#"
 method="createchild" argumentcollection="#form#"
 returnvariable="createchildRet">
</cfinvoke>


The component file


<!--- Create a new file child --->
        <cffunction name="createchild" output="true"
returntype="boolean" displayname="Create a new file child" hint="Create
a new file child and insert into the database">
        
         <!--- <cfdump var="#arguments#"> --->
        
        <!--- need to make sure that only one file of each type is
uploaded --->
                <cfquery name="qcheckdup" datasource="rawcms">
                SELECT * FROM rawcms_file_children
                WHERE file_id = #arguments.file_id# AND file_type_id =
#arguments.file_type# 
                </cfquery>
                
                <!--- get the file_type --->
                <cfquery name="qfiletype" datasource="rawcms">
                SELECT * FROM rawcms_file_types
                WHERE file_type_id = #arguments.file_type#
                </cfquery>
                
                <cfset errors ="">
                
                <cfif #qcheckdup.recordcount# EQ 1> 
                <cfset errors = listappend(errors,"You already have a
child of the file type #qfiletype.file_type# associated with parent file
#file_id#")>
                </cfif>
                
                <!--- If there are no errors --->
                <cfif #errors# EQ "">
                <cftry>
                
                        <!--- upload the file --->
                        <cffile action="UPLOAD"
                                filefield="arguments.file"
        
destination="/home/dev/webs/kryten.rawnet.com/htdocs/rawcms/files/"
                                nameconflict="MAKEUNIQUE"
                                accept="*/*">

                        <!--- construct the file_child_id --->
                        <cfset file_child_id =
"#arguments.file_id#_#arguments.file_type#.#serverfileext#">
                        
                        <cftry>
                                <!--- now we need to rename the file on
the server to the file_child_id --->
                        <cfoutput>
                                <cffile action="RENAME"
        
source="/home/dev/webs/kryten.rawnet.com/htdocs/rawcms/files/#serverfile
name#.#serverfileext#"
        
destination="/home/dev/webs/kryten.rawnet.com/htdocs/rawcms/files/#file_
child_id#"> 
                                </cfoutput>
                
                                <!--- catch any errors whilst renaming
--->
                                <cfcatch type="Any">
                                        <cfoutput>
                                        Could not rename file
                                        
                                        There has been a #cfcatch.type#
error 
                                        
                                        #cfcatch.message#
                                        </cfoutput>
                                </cfcatch>
                        </cftry>
                        
                        
                        <!--- insert the details into the
rawcms_file_children table --->
                        <cfquery name="qchildinsert"
datasource="rawcms">
                        INSERT INTO rawcms_file_children
                                (file_child_id,
file_id,file_type_id,file_extension)
                        VALUES
        
('#arguments.file_child_id#','#arguments.file_id#','#arguments.file_type
#','#arguments.serverfileext#')
                        </cfquery>
                        
                        <cfcatch type="Any">
                        <cfoutput>
                                        <cfrethrow>
                        There has been a #cfcatch.type# error 
                
                        #cfcatch.message#
                        </cfoutput>
                        </cfcatch> 
                        
                </cftry>
                <cfelse>
                        <cfoutput>#errors#</cfoutput>
                
                </cfif>
                
                <cfif errors EQ ""><cfreturn true> <cfelse> <cfreturn
false></cfif>
        </cffunction>
        <!--- end create new file child --->




> -----Original Message-----
> From: Spike [mailto:[EMAIL PROTECTED]]
> Sent: 17 January 2003 17:50
> To: [EMAIL PROTECTED]
> Subject: RE: [ cf-dev ] cffile in cfc's
> 
> Any chance of seeing the code you are using?
> 
> Stephen Milligan
> Team Macromedia - ColdFusion
> Co-author 'Reality Macromedia ColdFusion MX: Intranets and Content
> Management'
> http://spikefu.blogspot.com
> 
> > -----Original Message-----
> > From: Darren Adams [mailto:[EMAIL PROTECTED]]
> > Sent: 17 January 2003 17:44
> > To: [EMAIL PROTECTED]
> > Subject: RE: [ cf-dev ] cffile in cfc's
> >
> >
> > Yes,
> > The form itself is no different.
> >
> > All I have changed is the action page, which now invoked the
> > component.
> >
> > I think the error is occurring when I send in the #form#
> > scope as an argument.
> >
> > I've tried dumping the #form# and #arguments# scopes and are
> > identical so it does look as if the values are getting through.
> >
> > Arrrgh.
> >
> > -Darren
> >
> > > -----Original Message-----
> > > From: Steve Martin [mailto:[EMAIL PROTECTED]]
> > > Sent: 17 January 2003 17:27
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: [ cf-dev ] cffile in cfc's
> > >
> > > You using multipart/form-data as the enctype?
> > >
> > > -----Original Message-----
> > > From: Darren Adams [mailto:[EMAIL PROTECTED]]
> > > Sent: 17 January 2003 17:24
> > > To: [EMAIL PROTECTED]
> > > Subject: [ cf-dev ] cffile in cfc's
> > >
> > >
> > > Hello All,
> > >
> > > Has anyone had any experience with using cffile in a cfc ?
> > >
> > > I've just converted a perfectly working form action page
> > which uploads
> > > files to a cfc which is invoked and sends #form# to a function.
> > >
> > > If I try to run cffile in there I get the old chestnut about "form
> > field
> > > not containing a file".
> > >
> > >
> > > Any ideas ?
> > >
> > > -Cheers,
> > >
> > > Darren
> > >
> > >
> > >
> > > --
> > > ** Archive:
> > http://www.mail-archive.com/dev%> 40lists.cfdeveloper.co.uk/
> > >
> >
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED] For
> > > human help, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > > --
> > > ** Archive:
> > http://www.mail-archive.com/dev%> 40lists.cfdeveloper.co.uk/
> > >
> >
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED] For
> > > human help, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> >
> >
> > --
> > ** Archive:
http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED] For human help, e-mail:
> > [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> --
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For human help, e-mail: [EMAIL PROTECTED]
> 




-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to