CFFILE - Form Field Did Not Contain a File ??

I am trying to use cffile and I keep getting this error below. I have been searching everywhere and I see this error is common but I have not found a fix yet. Can someone please shed dome light. I would be so greatful.

Error:

The form field "D:\CFusionMX\runtime\servers\default\SERVER-INF\temp\wwwroot-tmp\neotmp65409.tmp" did not contain a file.

Thanks All!!
msidotiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RCorfmanCommented:
I found some info here:
http://www.houseoffusion.com/cf_lists/messages.cfm/forumid:4/Threadid:24097#121248
In case the link is gone in the future, it looks like the salient point is:

Type must be = "file"

That's what the error msg states.  I took it to mean that the file located
by the "filefield" attribute is not there.

My form tag is in my original post but the referenced input tag is:
<input size=70 type="text" name="LocalFilePath"
value="#Form.LocalFilePath#">

I think you change the input type on the field from type="text" to type="file"
mkishlineCommented:
Make sure that in the form you are submitting you specify <form action="some_page" method="post" enctype="multipart/form-data">
RCorfmanCommented:
what they are saying is the problem isn't the <cffile> command that is failing, but the type="text" on the <input> form field on the calling form. That needs to be type="file".
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

msidotiAuthor Commented:
Ok I have looked into the reply comments, but no cigars, the problem is the infomation that is getting passed to my Upload page (Upload.cfm) is coming from an applet.  The applet is able to pass two parameters - I m hoping I can use the parameters to upload the file they are -  userfile and userfile_parent.  Here is a little explanation -

userfile
Information about the files that have been uploaded will be available to the server side handler in the form of an array named userfile.  The exact contents of the array and the how to retrieve this (and other) data will depend on your chosen web scripting/programming language (in this case coldfusion).  You can expect to find at least the filename and file size. Some programming languages will provide additional information such a MIME types and temporary names assigned to the incoming files.

userfile_parent
This parameter contains the pathname of the top level folder on the client computer for the file upload as it appears to the applet.

Thanks for all your help!!  If you know of anything else please let me know.  I would be so greatful.
RCorfmanCommented:
This sounds equivalent. If the applet is passing in a path, that would be the same as the form field being set to text. What does the <cffile> command look like?
msidotiAuthor Commented:
cffile looks like this:

<cffile action="upload" filefield="#form["userfile[0]"]#" destination="#MyDestination#" nameconflict="skip">

When I do a cfoutput or cfdump to get what the actual value is for #form["userfile[0]"]# the valuse is

D:\CFusionMX\runtime\servers\default\SERVER-INF\temp\wwwroot-tmp\neotmp65418.tmp

I was told that - thats because when you upload a file it actually gets written to a temp directory first.  Anway, still no successful upload to the server.  Any other thoughts....
RCorfmanCommented:
But, I think that is the problem, based on the other thread that was included. The form field userfile[0] needs to be the actual file and needs to be a formfield type of FILE, not of text. It isn't the actual path of the file, but needs to be the file itself.

I think if you want to process the file and if the applet has already uploaded it, that you should look at using action="read" (or "readbinary" depending on the file).

Is the applet actually uploading it?
msidotiAuthor Commented:
No, unfortunately the file doesn't get uploaded to the server at all.  I am so stumped.  :(
msidotiAuthor Commented:
All the applet does is pass the variables to the Upload.cfm page.  The upload.cfm page is suppose to be responsible for uplading the file by means of CFFILE.
RCorfmanCommented:
I don't think that is how upload works. I think it is extracting an uploaded file from the client POST request. The server can't upload a file from a client, it only deals with the data that the browser uploaded. It sounds like the applet needs to format the data as if it were a "file" field for this to work, not a text field with a file path.
RCorfmanCommented:
Note that the file path looks like a path on the server??? maybe?
msidotiAuthor Commented:
Yes, the path that we are seeing is the server.  Also, I am not able to altar the applet so I am not sure what to do at this point.  I do believe that there is a way to address this issue, but at this point not sure how.
RCorfmanCommented:
have you confirmed that the file isn't actually there on the server?
msidotiAuthor Commented:
I am afraid I have checked several times.  I have actually gone on the server and not only checked the dstination but I have also done a search on the hard drive just to be extra sure and nothing unfortunately.
RCorfmanCommented:
In the documentation that I have under filefield it says "Required. Specifies the name of the form field used to select the file. Do not use pound signs(#) to specify the field name".  Try removing the # sign from your variable in the cffile statement.
msidotiAuthor Commented:
No luck I get this when I take out the # sign -

The form field "form[&aposuserfile[0]&apos]" did not contain a file.
RCorfmanCommented:
try using
filefield="form.userfile"
msidotiAuthor Commented:
No, I get the same thing -

The form field "form.userfile" did not contain a file.
RCorfmanCommented:
I'm afraid it all points back to the original question of why that error is happening. The error is fixed by using a form variable of type="file". Apparently that is not what this variable type is.  And, since it is coming from an applet that you can't change, I think you need to go back to the applet supplier and ask them if there is an option/parameter that will make the data a form variable of type file.
msidotiAuthor Commented:
Ok, I will check with the applet supplier.  Let you know how that goes, or if I find anything else out.  In the mean time thank you very much for all your help.  I really appreciate it.

Thank you!

Regards,
msidoti
RCorfmanCommented:
I wish I could have actually gotten it to work though. I think removing the # signs did help though, that is more the error message I'd expect to see.
msidotiAuthor Commented:
Hey RCorfman,

I was about to give up and I went through the posts here once again today and I discovered that you were right regarding part of your comment:

"I think if you want to process the file and if the applet has already uploaded it, that you should look at using action="read" (or "readbinary" depending on the file)."

For the cffile code on my upload.cfm I used this:

<cffile action="READBINARY" file="#form["userfile[0]"]#" variable="Message">
<cffile action="Write" file="C:\Inetpub\wwwroot\lite\uploaded\test.doc" output="#Message#"  nameconflict="MAKEUNIQUE" attributes="Normal">

and finally its working.  But now I have another problem - notice when I write the file I have to specify an an actual name and extension (ie test.doc in - C:\Inetpub\wwwroot\lite\uploaded\test.doc).  Is there a way to retrieve the filename with extension that I am uploading cause test.doc is just the name I hardcoded in and is not the actual name of the doc file I am uploading.  Not sure if this is possible but thought I would give it a shot.

Although, I am not out of the woods yet, I am not going to give up on this issue (I am a programmer not a quiter).

RCorfman Your the best!!
Thanks so much for everything.  Next time I guess I need to open my eyes a little wider when I am reading the posted replies.
RCorfmanCommented:
Yes, then the file is uploaded already. the cffile action="READBINARY" is actually just reading the file that is already on the server.  This is good news  :)

I would consider just moving the file using cffile action="move". You should be able to interrogate the name from the variable #form["userfile[0]"]# to see what the extention was, and then moving it to the new desired location. There is no reason to read it all the way into memory, then write it back out when you can just move it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
msidotiAuthor Commented:
Once again you are correct using cffile action="move" works great.  I guess that would be silly reading the content just to write it when I could just move it in one simple step.  However the file name when I go to check the server is comping up as neotmp65409.tmp. :(  

Even if I check the variable #form["userfile[0]"]# by doing a cfoutput to screen I get this:    

C:\CFusionMX\runtime\servers\default\SERVER-INF\temp\wwwroot-tmp\neotmp25037.tmp

Is there any other way to get the file name that you can think of?

Thanks again you have been such a great help.
RCorfmanCommented:
What is the value of form.userfile_parent?
RCorfmanCommented:
Actually, or, if userfile is an array, what are the values of the other array elements...  I'm hoping they are providing you the client file name somewhere in the data the applet is providing.  If so, you can use that. If not, then I don't think there is any way. I suspect it is in the passed variables though.
RCorfmanCommented:
Ohh, one other thing, you might want to post the actual name of the applet class here somewhere so that if others have problems, and search EE for the applet class name, they would find some information on it. Not necessary, but may be good.
JeffHowdenCommented:
When in doubt, use <cfdump var="#form#"> inside a <cfsavecontent> block and write that to a file on the server.  Pull up the resulting file in a browser and see what you've got.  If that doesn't give you enough info, add a <cfdump var="#cgi#"> to the <cfsavecontent> block as well.  The combination of the two will most certainly get you the information necessary to accomplish the task at hand, provided the parts outside your control are obeying the requisite specifications.

As an aside, it should be noted that the <cffile> tag with an action of upload is really just a fancy version of the same tag with an action of move.  The form field you give it is really just the temporary path (and temp filename) of the file as it's been uploaded onto the system by the server.  It goes beyond using the move action by creating a cffile struct with keys that indicate things about client and server filenames, extensions, size, whether or not there were conflicts with any file that already resided on the server at the specified path with the same name as the uploaded file, how that conflict was handled (as specified by the value nameconflict attribute), etc.  So, it makes sense that you're able to use <cffile> with an action of move.  Unfortunately, as you're discovering, doing so doesn't include all the other relevant bits of info you need to complete the move appropriately.
JeffHowdenCommented:
I believe that sufficient recommendations have been made by the experts and the question's author simply has lost interest.
msidotiAuthor Commented:
<cfloop from="0" to="9999" index="ii">
      <cftry>
            <cfif len(form["userfile[#ii#]"])>
                  <cfset p = 1>
            </cfif>
            <cfcatch type="Any">
                  <cfset p = 0>
                  <cfbreak>
            </cfcatch>
      </cftry>
      <cfif p and len(form["userfile[#ii#]"])>
            <cffile action = "upload"
            fileField = "form.userfile[#ii#]"
            destination = "#your-destination-path#/"
            nameConflict = "MakeUnique"
            attributes = "normal">
                  <cfelse>
              <cfbreak>
      </cfif>      
</cfloop>
msidotiAuthor Commented:
Here is the answer:

<cfloop from="0" to="9999" index="ii">
     <cftry>
          <cfif len(form["userfile[#ii#]"])>
               <cfset p = 1>
          </cfif>
          <cfcatch type="Any">
               <cfset p = 0>
               <cfbreak>
          </cfcatch>
     </cftry>
     <cfif p and len(form["userfile[#ii#]"])>
          <cffile action = "upload"
          fileField = "form.userfile[#ii#]"
          destination = "#your-destination-path#/"
          nameConflict = "MakeUnique"
          attributes = "normal">
                  <cfelse>
             <cfbreak>
     </cfif>    
</cfloop>

Please excuse my delay.

Regards,
msidoti
RCorfmanCommented:
I think points should be awarded. Please note comments in {http:#15983112} and prior.
I clearly led msidoti to a solution to their original problem. Then the question morphed into a second.

"Hey RCorfman,
I was about to give up and I went through the posts here once again today and I discovered that you were right regarding part of your comment:
"I think if you want to process the file and if the applet has already uploaded it, that you should look at using action="read" (or "readbinary" depending on the file)."
......
and finally its working.  But now I have another problem...."
msidotiAuthor Commented:
The answer to the question has been posted  - not sure what else you are looking for?
I cold not get files to upload using cffile - was not working and finally issue was solved so I posted the solution:

<cfloop from="0" to="9999" index="ii">
     <cftry>
          <cfif len(form["userfile[#ii#]"])>
               <cfset p = 1>
          </cfif>
          <cfcatch type="Any">
               <cfset p = 0>
               <cfbreak>
          </cfcatch>
     </cftry>
     <cfif p and len(form["userfile[#ii#]"])>
          <cffile action = "upload"
          fileField = "form.userfile[#ii#]"
          destination = "#your-destination-path#/"
          nameConflict = "MakeUnique"
          attributes = "normal">
                  <cfelse>
             <cfbreak>
     </cfif>    
</cfloop>

Regards,
msidoti
RCorfmanCommented:
msidoti, the question is this... are you saying that we did not help you and that none of our conversation aided in you getting to the right anwer. If we helped you, then points should be awarded, not refunded back to you.  We all want to see you get to a good solution, it is frustrating all around if we helped get you there, then you turn around and say close this, I want a refund, nobody helped.

If there was assistance in getting you to the solution, then points should be awarded, not refunded.

If one problem was solved, then we start helping on another problem, that doesn't mean that it isn't still a second problem. and the first should have been closed out.  Consider this from the perspective of those of us who are trying to HELP you come to a solution...
msidotiAuthor Commented:
Pardon me Rcorfman, but I never said that you or anyone else did not help me with my issue / posted question.  I believe that everyone who comments in this forum or any forum for that matter is a BIG HELP, regardless of weather the issue is addressed or not by the posted comments.  In any case, I never asked for any points to be refunded, I was simply pointing out that I have found a solution and I posted it.  To be honest I am not here for points – I join forums like this seeking help and I also find it rewarding to help others out there that are struggling with issues as well.  I am not concerned about the points.  

Thank you,
msidoti
RCorfmanCommented:
When you posted and asked to have this question closed, by definition, you are saying that you came up with your own answer, unaided, and that the question is closed with points refunded. That may not have been your intent, but that is how it is interpretted when you request the moderators to close it. If you were aided, then you should determine to split points between those who helped, or to assign them to one answer. Either way, you pick a key post that aided or provided the solution.

The link below explains how to close questions and what options you have.
http://www.experts-exchange.com/help.jsp#hs5

I think this is just a misunderstanding of the process. Closing this is normally just in your own hands, they are closed by assigning points.
RCorfmanCommented:
I believe the PAQ occured by msidoti. msidoti , thanks for bearing with us. I hope we can all be of assistance with future problems.  pinaldave, great clarification. thanks.
xoundboyCommented:
By examining an upload script I wrote a while back (which worked) I discovered why this error occurs.

THERE IS A VERY SIMPLE SOLUTION TO THIS PROBLEM....READ ON.....

When using cffile to upload a file that has been passed through a <cfinput type="file"...> form field, the filefield="myFile" attribute cannot contain the form variable name. It must be substituted with a string containing the form variable name, like so...


the form page...

<cfform action="uploadAction.cfm" method="post" enctype="multipart/form-data" name="upload">
    <cfinput name="uploadFile" type="file" onChange="submit()">
</cfform>

and the action page...

<cfset currentFile = 'form.uploadfile'>
<cffile
    action="upload"
    filefield="#currentFile#"
    destination=#expandpath('../uploads')#
    nameconfilct="makeunique">

it's that easy.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.