• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

how do you upload a file in coldfusion.

My code seem to be working on my older coldfusion server.

So I've moved my project to a different server.  When I click on the import-file button i'm having an error on line 60.

This is my line of code #60:

<!--- old one didn't work --->
<!--- <CFFILE ACTION="read" FILE="#application.directory_path#\members\toolkit\import\#parsed_file_name#" variable="qrydata">--->
       
<!---This is the new one it's working I can browse for the file  --->
    <CFX_SFILE USERNAME="xxxxxx" PASSWORD="xxxxxx"  ACTION="read" FILE="#application.directory_path#\members\toolkit\import\#parsed_file_name#" variable="qrydata">

When I select the file I got a coldfusion error what this mean.
This is the errors.

Error processing CFX custom tag "CFX_SFILE". The CFX custom tag "CFX_SFILE" was not found in the custom tag database. Please be sure to add custom tags to the database before using them. If you have added your tag to the database then you should check the spelling of the tag within your template to insure that it matches the database entry. <br>The error occurred on line 61.
import-file.jpg
errors.jpg
0
koila
Asked:
koila
  • 11
  • 7
  • 4
  • +1
3 Solutions
 
Pravin AsarPrincipal Systems EngineerCommented:
Uploading an file is a very simple thing with Coldfusion.

<cfif isDefined("fileUpload")>
  <cffile action="upload"
     fileField="fileUpload"
     destination="C:\docs">
     <p>Thankyou, your file has been uploaded.</p>
</cfif>
<form enctype="multipart/form-data" method="post">
<input type="file" name="fileUpload" /><br />
<input type="submit" value="Upload File" />
</form>
0
 
Pravin AsarPrincipal Systems EngineerCommented:
Looks like your new server is missing custom coldfusion tag

CFX_SFILE

 ColdFusion Extension (CFX) tags are custom tags that you write in Java or C++. Generally, you create a CFX tag to do something that is not possible in CFML. CFX tags also let you use existing Java or C++ code in your ColdFusion application.
0
 
_agx_Commented:
(no points ...)

For it to work, you need to register that custom tag on your new server.  Find the DLL (C++ tag) or .class file (java tag) for the custom tag and register it in the CF Administrator.

For instructions, see Building Custom CFXAPI Tags :
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=CFXTags_4.html
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
Gurpreet Singh RandhawaWeb DeveloperCommented:
if you want o use same tag, Follow Suggestion of _agx, else check Pravinasar's file  Functionality,

If you need additional features in Uploading check this tutorial

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/A_2888-Uploading-a-File-in-Coldfusion.html
0
 
Pravin AsarPrincipal Systems EngineerCommented:
I suspect the custom tag was meant for multiple file upload.

Since CF9, mutliple file upload functionality is available.

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec18238-7fd0.html
0
 
_agx_Commented:
@pravinasar - I did a quick search and found very few references. This one says a specific host used it for security reasons under CF5 - and that it doesn't work in CF6+.


For Primus servers running Coldfusion 5, Primus has determined that the security model which is build into Coldfusion 5.0 is not suitable for a shared hosting environment. .. for security purposes, Primus has disabled the CFFILE, CFDIRECTORY, and CFFTP tags on the UNIX servers running Coldfusion 5.0. Primus has developed a number of secure custom Coldfusion tags for Coldfusion 5.0 that provide similar functionality. ... These tags are not available on servers running Coldfusion MX.


@koila - Did you switch hosts too? What version of CF are you running?
0
 
koilaAuthor Commented:
yes, I've switch the hosts too. I will found out from the provider.
0
 
_agx_Commented:
There's a comment in the OP about cffile: "old one didn't work".  Does CFFILE work on your new host?

You can check your version by dumping the server scope, under "coldfusion":

      <cfdump var="#server#">
0
 
Pravin AsarPrincipal Systems EngineerCommented:
On my server, to help me quickly identify the issues, I use test code.

Here it is

<cfoutput>
<h1>HOST NAME: #GetHostPath()#</h1>
<h1>HOST ROOT DIR: #ExpandPath("/")#</h1>
</cfoutput>
<h1>CGI VARIABLES</h1>
<!--- Get CGI Variable --->
<cfdump var="#CGI#"/>
<!--- Get HTTP Variables --->
<h1>HTTP VARIABLES</h1>
<cfdump var="#HTTP#"/>
<cfscript>
function GetHostPath() {
      hostname=cgi.http_host;
      if (cgi.https_on is "on") {
            hostname= 'https://' & hostname;
      }
      else {
            hostname= 'http://' & hostname;
      }
      return hostname;
}
</cfscript>
<cfoutput>This is a Server and Session Information</cfoutput>

<h1>CF Server Information</h1>
<cfdump var="#server#">

<h1>Session Information</h1>
<cfdump var="#session#">
0
 
koilaAuthor Commented:
how i'm able to convert this to cf_file.


<CFX_SFILE USERNAME="xxxxxx" PASSWORD="xxxxxx"  ACTION="read" FILE="#application.directory_path#\members\toolkit\import\#parsed_file_name#" variable="qrydata">
0
 
koilaAuthor Commented:
I will have to review the coldfusion with the admin person.

or I should create a .cfm file and run this code in the ie browser. I will have to add my domain name right? to the http://www.xxxx.com

<cfoutput>
<h1>HOST NAME: #GetHostPath()#</h1>
<h1>HOST ROOT DIR: #ExpandPath("/")#</h1>
</cfoutput>
<h1>CGI VARIABLES</h1>
<!--- Get CGI Variable --->
<cfdump var="#CGI#"/>
<!--- Get HTTP Variables --->
<h1>HTTP VARIABLES</h1>
<cfdump var="#HTTP#"/>
<cfscript>
function GetHostPath() {
      hostname=cgi.http_host;
      if (cgi.https_on is "on") {
            hostname= 'https://' & hostname;
      }
      else {
            hostname= 'http://' & hostname;
      }
      return hostname;
}
</cfscript>
<cfoutput>This is a Server and Session Information</cfoutput>

<h1>CF Server Information</h1>
<cfdump var="#server#">

<h1>Session Information</h1>
<cfdump var="#session#">
0
 
_agx_Commented:
You only need one line of CF code to check the version:

        <cfdump var="#server#">

To convert the custom tag stuff to cffile, try the code in pravinasar's first post:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_28137293.html#a39192079
0
 
koilaAuthor Commented:
I got this error:

The form field "fileUpload" did not contain a file.  <br>The error occurred on line 64.

This is my code:

  <cffile action="upload"
     fileField="fileUpload"
     destination="#application.directory_path#\members\toolkit\import\#parsed_file_name#">


<!--- My old code --->        
<!--- Start
            <CFFILE ACTION="upload" FILE="#strAttachment#" nameconflict="OVERWRITE" DESTINATION="#application.directory_path#\members\toolkit\import\#parsed_file_name#">
                  End --->
0
 
koilaAuthor Commented:
This is overview of my code.
<cfif xaction eq "submit">
	<!---Check for submission errors--->
	<cfif strAttachment eq "">
		<cfset strAttachment_err = "Y">
		<cfset err = "Y">
	</cfif>
	
	<cfif err eq "N">
		<!---Process file to import--->
		<cfif form.strAttachment neq "">
			<!---Get the file name from the path--->
			<cfset parsed_file_name = #GetFileFromPath(form.NameHidden)#>
			
			<!---Upload the file--->   
            <!--- My old code --->         
			<!--- Start
            <CFFILE ACTION="upload" FILE="#strAttachment#" nameconflict="OVERWRITE" DESTINATION="#application.directory_path#\members\toolkit\import\#parsed_file_name#">
			End --->
            

  <cffile action="upload"
     fileField="fileUpload"
     destination="#application.directory_path#\members\toolkit\import\#parsed_file_name#">


            
           <!--- <CFX_SFILE USERNAME="actca" PASSWORD="Mex" ACTION="upload" FILE="#strAttachment#" nameconflict="OVERWRITE" DESTINATION="#application.directory_path#\members\toolkit\import\#parsed_file_name#">--->

            
          
		
			<!---Read the file--->
			<CFFILE ACTION="read" FILE="#application.directory_path#\members\toolkit\import\#parsed_file_name#" variable="qrydata">
            <!---<CFX_SFILE USERNAME="actca" PASSWORD="Mex"  ACTION="read" FILE="#application.directory_path#\members\toolkit\import\#parsed_file_name#" variable="qrydata">--->
            
			<!---Loop through the file to set teh data variable--->
			<cfset data = "">
			<cfloop query="qrydata">
				<cfset data = "#Trim(data)#
#line#"></cfloop>

Open in new window

0
 
koilaAuthor Commented:
AGX, what do you think how i'm able to fix this issue.
0
 
Pravin AsarPrincipal Systems EngineerCommented:
Koila,

Here is a simple sample code for multiple file uploads.

Meanwhile I will dig into your posted code, to point out the issues.


<!--- FILE: FILEUPLOAD.CFM --->

<cfform name="f1"  method="post" action="processfiles_action.cfm">
      <table cellpadding="20" cellspacing="20" width="800">
            <tr>
                  <th>
                        <cffileupload url="uploadfile_action.cfm" width="750" height="600"  maxuploadsize="10" bgcolor="##d7c19f"/>
                  </th>
            </tr>
            <tr>
                  <th style="text-align:right;">
                        <cfinput type="submit" name="submit" value="Submit" />
                  </th>
            </tr>
      </table>
</cfform>
<cfexit>

<!--- FILE: uploadfile_action.cfm --->

<cffile action="uploadall" destination="#expandPath('./myuploads')#" nameconflict="overwrite" />
0
 
Pravin AsarPrincipal Systems EngineerCommented:
You need "fiefield" attribute with <cffile> tag.

This specified the name of form field used to select the file
e.g

<!--- EXAMPLE --->

<!--- Check to see if the Form variable exists. --->
<cfif isDefined("Form.FileContents") >
    <!--- If TRUE, upload the file. --->
    <cffile action = "upload"
        fileField = "FileContents"
        destination = "c:\files\upload\"
        accept = "text/html"
        nameConflict = "MakeUnique">
<cfelse>
    <!--- If FALSE, show the Form. --->
    <form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>
        name="uploadForm" enctype="multipart/form-data">
        <!---- FILE IS SELECTED BY THIS FIELD --->

        <input name="FileContents" type="file">
        <br>
        <input name="submit" type="submit" value="Upload File">
    </form>
</cfif>
0
 
koilaAuthor Commented:
how i'm able to fixed into my code?
0
 
Pravin AsarPrincipal Systems EngineerCommented:
Can you upload your form code and code you would like me fix.

Thanks
0
 
koilaAuthor Commented:
it didn't work yet. I 'm still figuring out so I put it a side for today I will take a look tomorrow on this code. I will have another question today.
0
 
koilaAuthor Commented:
Hello,

it didn't work :( :( I will upload the file. Could you please help me.
0
 
koilaAuthor Commented:
The error is happens on line 64.


 <cffile action="upload"
     fileField="fileUpload"
     destination="#application.directory_path#\members\toolkit\import\#parsed_file_name#">
     <p>Thankyou, your file has been uploaded.</p>

What is causing this error.

Thank you very much for your help and advise.
update-.txt
import-file.jpg
i-am-to-browse.jpg
error.jpg
0
 
koilaAuthor Commented:
thank you.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 11
  • 7
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now