<cffile action="upload" destination="#arguments.destination#" filefield="arguments.fileField" accept="#arguments.acceptType#" nameconflict="#arguments.nameConflict#" />

Suggestion: replace < and > with &lt; and &gt; and wrap a cfoutput pair around this line to see just what exactly you are trying to tell ColdFusion to do. You can stick the result in your action file for a quick output check.

Hint: your form file variable was called uploadFile ie FORM.uploadFile. Structs are passed by reference, individual structure elements / keys are *not*. The error message completes the hint.

Particularly for people learning CFCs, I would suggest getting the intended code working in the .cfm (eg: action page) first, then creating a function in the same page and putting the code in that, passing the required arguments. Then moving it to a CFC's function.

HTH
Aaron
PS: If it annoys the cr4p out of you that I don't give the answer but encouraged you to learn to debug instead, let me know.

Ryan Everhart wrote:
Hey guys,
I'm finally getting around to coding this and I'm getting the dreaded "does not contain a file" error. Below is the error and the code, can anyone see what I'm doing wrong?

CF Error:
The form field "arguments.fileField" did not contain a file.

Form code:
http://codeshare.ulatu.com/mar01c39 <http://codeshare.ulatu.com/mar01c39>

Action code to call CFC:
http://codeshare.ulatu.com/mar47f18

Actual Function within CFC:
http://codeshare.ulatu.com/mare8dee

Thoughts anyone?

Ryan


On 3/29/07, *Sammy Larbi* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Anthony Israel-Davis wrote, On 3/29/2007 11:39 AM:
    >
    >
    > I would suggest a design that has a high amount of reuse (that's
    one of
    > the reasons for using a CFC!) so instead of passing in the
    entire form
    > structure and depending on the form names, you may want to consider
    > passing in each attribute individually and returning the cffile
    variable
    > for additional processing.  Here's an example:
    >
    >
    That's true.  You should only use the entire form scope if you
    intend to
    you all of it (or, perhaps if you have another really good reason)



    > <cffunction name="upload" access="public" output="false"
    > returntype="struct" hint="returns the cffile struct">
    >               <cfargument name="fileField" type="string"
    > required="true" hint="This is the name of the form field that
    contains
    > the file">
    >               <cfargument name="acceptType" type="string"
    > required="false" default="" hint="Valid File Types">
    >               <cfargument name="nameConflict" type="string"
    > required="false" default="MakeUnique" hint="nameConflict value for
    > cffile">
    >
    > ... MORE CODE HERE ...
    > <cfreturn cffile> <!--- OR Whatever you name your return
    variable --->
    >
    > </cffunction>
    >
    > anthony
    >
    >
    > -----Original Message-----
    > From: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> [mailto:
    [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>] On Behalf Of Sammy
    > Larbi
    > Sent: Thursday, March 29, 2007 9:12 AM
    > To: [email protected] <mailto:[email protected]>
    > Subject: Re: [CFCDEV] Uploading Files and CFCs
    >
    > Ryan Everhart wrote, On 3/29/2007 6:25 AM:
    >
    >> This may be a dumb question, but can you use a cfc to upload files?
    >> Do they have access to the form scope when executed?  The way my
    >> application is being built is sorta like a framework where I have
    >> pages called views which display all my data then I have action
    pages
    >> which do stuff like add/remove/update data in the db via
    CFCs.  So my
    >> question is, on an action page can I call a component that will be
    >> able to upload a picture from a form, or do i have to do the actual
    >> upload on the action page itself then do any other actions
    (rename,
    >> move, add file name to db) on the cfc.  Thanks!  I've been thinking
    >> about this all night but haven't tested it out yet.
    >>
    >
    > Try it out!  CFCs do have access to the form scope, but generally I
    > think people tell you to only depend on a structure, and pass in the
    > form scope instead.  I think I have actually tried uploading a
    file in
    > one, so assuming I'm not making up past experiences (which, on
    occasion
    > I probably have done), I'm pretty sure it will work.
    >
    >
    >
    > You are subscribed to cfcdev. To unsubscribe, please follow the
    > instructions at http://www.cfczone.org/listserv.cfm
    >
    > CFCDev is supported by:
    > Katapult Media, Inc.
    > We are cool code geeks looking for fun projects to rock!
    > www.katapultmedia.com <http://www.katapultmedia.com>
    >
    > An archive of the CFCDev list is available at
    > www.mail-archive.com/[email protected]
    <http://www.mail-archive.com/[email protected]>
    >
    >
    >
    >
    >
    > You are subscribed to cfcdev. To unsubscribe, please follow the
    instructions at http://www.cfczone.org/listserv.cfm
    >
    > CFCDev is supported by:
    > Katapult Media, Inc.
    > We are cool code geeks looking for fun projects to rock!
    > www.katapultmedia.com <http://www.katapultmedia.com>
    >
    > An archive of the CFCDev list is available at
    www.mail-archive.com/[email protected]
    <http://www.mail-archive.com/[email protected]>
    >
    >
    >
    >



    You are subscribed to cfcdev. To unsubscribe, please follow the
    instructions at http://www.cfczone.org/listserv.cfm

    CFCDev is supported by:
    Katapult Media, Inc.
    We are cool code geeks looking for fun projects to rock!
    www.katapultmedia.com <http://www.katapultmedia.com>

    An archive of the CFCDev list is available at
    www.mail-archive.com/[email protected]
    <http://www.mail-archive.com/[email protected]>




--
Ryan Everhart
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Blogging @ http://blog.ryaneverhart.com/

Have you gotten your InstantSpot yet?
http://www.instantspot.com/referral?c=n3fpjscv
You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to