Copy link to clipboard
Copied
Hi,
I am using Cold Fusion 11.
When I browse to obtain the file to upload, the location and file in the text box is: S:\App\test.xml
<cfform action="fileaction.cfm" enctype="multipart/form-data" method="post">
<P>Enter the complete path and filename of the file to upload:</P>
<CFINPUT type="file" name="FileUp" size="90">
<P><input type="Submit" value="Upload"></P>
</CFform>
But when the above code execute, the following location appears in the variable:
D:\ColdFusion11\cfusion\runtime\work\Catalina\localhost\tmp\neotmp803964384012527716.tmp
When I remove the enctype="multipart/form-data" from the code, the file is found, but the error message in the Cold Fusion admistration is:
Invalid content type: application/x-www-form-urlencoded.The files upload action requires forms to use enctype=""multipart/form-data"".
Is there something in the Cold Fusion 11 administration or configuration files that needs to be changed?
This was not an issue with Cold Fusion 9.
Mike
Have you tried changing the cffile tag to use accept="text/xml,application/xml,application/octet-stream" ? The IIS MIME type shouldn't have a bearing here, as this is being handled server-side by ColdFusion.
-Carl V.
Copy link to clipboard
Copied
That is expected behavior. When you upload a file through a form post to ColdFusion, it will place the file in a temporary folder on the server. In the CFM file that you use to process the form submittal (fileaction.cfm), you need to use <cffile action="upload"> to move the file to a permanent location. Please note that for reasons of security, avoid moving the file to a location within the webroot. Place it in a folder outside the webroot, but that the ColdFusion service has read/write access to.
Also, from the code sample you provided, there is no need to use CFFORM/CFINPUT. You can use the HTML FORM/INPUT tags instead and make things simpler.
-Carl V.
Copy link to clipboard
Copied
When I selected the file location, S\App\test.xml, from the selection screen, the value in the selection variable is not what I selected when the fileaction.cfm executes.
It is, D:\ColdFusion11\cfusion\runtime\work\Catalina\localhost\tmp\neotmp803964384012527716.tmp
This before the cffile execution.
Mike
Copy link to clipboard
Copied
Again, this is expected behavior. Once the form is submitted from the client (your browser), the file content is embedded by the client into the form payload (an actual copy of the file is attached to the form submittal). This is basic HTML process, regardless of what server-side solution you have on the back end (PHP, ASP.NET, etc.). Operationally, ColdFusion doesn't really care where the file originally existed; it gets passed the form payload, puts the attached file in a temporary folder, and waits for you to do something with it (via CFFILE). Once you do the <cffile action=upload>, you do have access to the original file path and name via status attributes (see cffile action="upload" in the docs). Specifically, you have access to read-only status variables cffile.clientDirectory, cffile.clientFile, cffile.clientFileExtension, and cffile.clientFileName (or, if you provide the result="myVariableName" attribute on your cffile tag, you can access the same variables as myVariableName.clientDirectory, etc.)
-Carl V.
Copy link to clipboard
Copied
I checked CF9 and the value in the variable from the selection screen is pointing to a tmp file.
Then the issue is with the cffile statement.
<cffile action="upload" destination="#upload#" nameconflict="overwrite" accept="text/xml,application/octet-stream" filefield="form.FileUp">
The #upload# contains the location where the data file is to be placed.
The error message in Cold Fuision 11 admin is the following:
The MIME type or the Extension of the uploaded file application/xml was not accepted by the server.Only files of type text/xml can be uploaded. Verify that you are uploading a file of the appropriate type.
The file has the xml extension.
I checked in IIS for the website MIME Types and there is an entry for .xml entension with an MIME Type of text/xml
Mike
Copy link to clipboard
Copied
Have you tried changing the cffile tag to use accept="text/xml,application/xml,application/octet-stream" ? The IIS MIME type shouldn't have a bearing here, as this is being handled server-side by ColdFusion.
-Carl V.
Copy link to clipboard
Copied
userCold9 wrote:
Hi,
I am using Cold Fusion 11.
When I browse to obtain the file to upload, the location and file in the text box is: S:\App\test.xml
<cfform action="fileaction.cfm" enctype="multipart/form-data" method="post">
<P>Enter the complete path and filename of the file to upload:</P>
<CFINPUT type="file" name="FileUp" size="90">
<P><input type="Submit" value="Upload"></P>
</CFform>
But when the above code execute, the following location appears in the variable:
D:\ColdFusion11\cfusion\runtime\work\Catalina\localhost\tmp\neotmp803964384012527716.tmp
<cffile action="upload" destination="#upload#" nameconflict="overwrite" accept="text/xml,application/octet-stream" filefield="form.FileUp">
I have 2 suggestions.
1) The ColdFusion documentation requires that you set the destination attribute of the cffile tag to the absolute path of an existing directory. Otherwise, ColdFusion will use its system temp directory as default destination. Hence, D:\ColdFusion11\cfusion\runtime\work\Catalina\localhost\tmp\neotmp803964384012527716.tmp. It implies that the value of #upload# is not the absolute path of an existing directory.
2) Use <form> in place of <cfform>. Cfform's extra script is just bagage that weighs the page down for nothing.