Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading csv file in CF

Status
Not open for further replies.

ANGELFIRE

Technical User
Sep 22, 2001
8
0
0
US
Hi,

I am new to coldfusion, html and javascript. I have a requirement where i have to allow the user to upload a comma-separated-values file (.csv). I am using CFFILE tag to upload the file. Everything works fine in IE. The same form also allows me to upload .txt and .doc files in Netscape 6.0 except for .csv file. I am unable to identify the problem.

FYI : this is the error that i am gettting

Error in CFFILE tag The form field specified in the CFFILE tag (UPLOAD) does not contain an uploaded file. Please be sure that you have specified the correct form field name.

Can anybody help me with this.
 
Here is my code :

<CFIF parameterExists(fileName)>
<CFIF #Form.fileName# NEQ &quot;&quot;>

<CFFILE ACTION = &quot;UPLOAD&quot; FILEFIELD='upload'
DESTINATION=&quot;d:\webroot\intranet\chethamstuff\uploadedfiles\&quot; NAMECONFLICT=&quot;OVERWRITE&quot;>

<CFIF parameterexists(FILE.ClientDirectory)>
<CFSET fileName = &quot;d:\webroot\intranet\chethamstuff\uploadedfiles\&quot; & #File.ServerFile#>
<CFFILE ACTION = &quot;READ&quot; FILE= #fileName# VARIABLE=&quot;theList&quot;>

<CFSET theList = ReplaceNoCase(theList, &quot;#CHR(13)#&quot;, &quot;&quot; , &quot;ALL&quot;)>
<CFSET theList = ReplaceNoCase(theList, &quot;#CHR(10)#&quot;, &quot;&quot; , &quot;ALL&quot;)>
<CFSET theList = ReplaceNoCase(theList, &quot;#CHR(32)#&quot;, &quot;&quot; , &quot;ALL&quot;)>


<CFFILE ACTION=&quot;WRITE&quot; FILE=#fileName# OUTPUT=&quot;#theList#&quot; ADDNEWLINE=&quot;NO&quot;>
</CFIF>


<CFOUTPUT>#File.ServerFileName#</cfoutput>
</CFIF>
</CFIF>
 
I'm a little confused by your code. It looks like you're calling your file input box &quot;filename&quot; yet you reference is as &quot;upload&quot; in your cffile tag. It looks to me that your problem is that your <cffile> tag should be like this:

<CFFILE ACTION = &quot;UPLOAD&quot; FILEFIELD=&quot;filename&quot; ...

Let me know if I'm missing something,
GJ
 
I think I might know what the problem is. I came across this as well (albeit a different file type).

The problem isn't in your code. Just make sure that you have: multipart/form-data in your form page.

Example:

<form action=&quot;whatever.cfm&quot; name=&quot;NameofYourForm&quot; method=&quot;Post&quot; ENCTYPE=&quot;multipart/form-data&quot;>

blah.. blah..

</form>

Good luck!

GC


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top