• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFFILE Upload question

Explorer ,
Sep 19, 2006 Sep 19, 2006

Copy link to clipboard

Copied

I have a question and I believe I know the answer but I want to ping all of you to see what you say. I am developing an application using Mach-II. I would like to upload a file. I have no problem seeing the filefield in my listener. Technically I could just process the cffile action="upload" right there in the listener, but instead I would like to stick to convention and upload it in my FileService component instead. Is there a way of passing the form file field to the service and then processing the upload?

I have a feeling based on the way that CFFILE is built this is not possible. Please advise. I will be happy to resolve any confusion my message may have.
TOPICS
Advanced techniques

Views

437

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Sep 20, 2006 Sep 20, 2006
My question has been answered by Brian Rinaldi over at Remote Synthesis ( http://www.remotesynthesis.com/blog). He wrote an article on how to deal with uploads via Model-Glue. He was able to clarify his post for me and now I understand what you have to do.

What it comes down to is that you have to submit the name of the fileField in a hidden input field (for lack of a better way at this time) and pass that through your methods rather than the value of your fileField.

Votes

Translate

Translate
Explorer ,
Sep 19, 2006 Sep 19, 2006

Copy link to clipboard

Copied

Don't know about Mach II but passing to a cfc is as follows:
<cfinvoke component="somecfc" method="fileUpLoad" fileField="nameOfFileInput">

The value passed in the fileField variable is the actual name of the input type="file"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 19, 2006 Sep 19, 2006

Copy link to clipboard

Copied

I keep getting "backupDoc" does not contain a file, yet when I dump it, it displays the location to the temporary file. Then I have also run a FileExists on it and it does exist.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 20, 2006 Sep 20, 2006

Copy link to clipboard

Copied

Post your code and we can see if we see something

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2006 Sep 20, 2006

Copy link to clipboard

Copied

My question has been answered by Brian Rinaldi over at Remote Synthesis ( http://www.remotesynthesis.com/blog). He wrote an article on how to deal with uploads via Model-Glue. He was able to clarify his post for me and now I understand what you have to do.

What it comes down to is that you have to submit the name of the fileField in a hidden input field (for lack of a better way at this time) and pass that through your methods rather than the value of your fileField.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 29, 2006 Nov 29, 2006

Copy link to clipboard

Copied

LATEST
Hi

I m having trouble with a similar project. I have a form which allows the user to choose a maximum of 3 upload fields. I have a filesystem.cfc file which handles the upload. the cfc code is below:

<cffunction name="upload" access="public" output="false" returntype="struct">
<cfargument name="formFieldName" required="true" type="string" />
<cfset var stReturn = structNew() />
<cfset var stFileUpload = "" />
<cffile action="upload" filefield="formFieldName" destination="#variables.destination#" nameconflict="makeunique" result="stFileUpload" />

<cfset stReturn.success = true />
<cfset stReturn.sourceFile = stFileUpload.serverFile />
<cfreturn stReturn />
</cffunction>

when the user submits the form I use the following code is processed:

<!--- loop through fields --->
<cfloop from="1" to="#num#" index="counter">
<cfset fileUpload = fileSystem.upload(formfieldName=FORM["file"&counter]) />
</cfloop>

but i get the error message "The form field "formFieldName" did not contain a file".

any help or advice is appreciated, I had a look at Brian Rinaldis blog but its not too clear to me how it works.

regards

shaun

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation