Skip to main content
tommuck1
Inspiring
November 19, 2014
Question

unicode file upload

  • November 19, 2014
  • 1 reply
  • 630 views

I have tried everything to get ColdFusion to accept a unicode filename in an uploaded file, such as 饺ぞぎゅびゃツァ 鄩.txt or unicode_♫.txt. The cffile tag rejects the file (cffile.filewassaved property always false). I have tried all of the following:

meta tag <meta http-equiv="Content-Type" content="text/html;charset=utf-8">

cfprocessingdirective tag <cfprocessingdirective pageencoding="utf-8">

cfcontent tag   <cfcontent type="text/html; charset=utf-8">

setencoding

<cfset SetEncoding("url","utf-8")>

  <cfset SetEncoding("form","utf-8")>

cffile charset attribute set to charset="UTF-8"

Nothing seems to work. Does ColdFusion not accept unicode filenames?

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
November 19, 2014

I had no problems with it at all. I created the following text file:

饺ぞぎゅびゃツァ 鄩.txt

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Then I uploaded the file using the code,

uploadForm.cfm

<cfif isDefined("Form.FileContents") >

    <cftry>

    <cffile action = "upload"

        fileField = "FileContents"

        destination = "c:\uploads"

        accept="text/plain"

    nameConflict="overwrite">

 

    <cfif cffile.FileWasSaved>Upload done!</cfif>

    <cfcatch type="any">

        <cfdump var="#cfcatch#">

    </cfcatch>

    </cftry>

<cfelse>

    <form method="post" action="uploadForm.cfm" enctype="multipart/form-data">

        <input name="FileContents" type="file">

        <br>

        <input name="submit" type="submit" value="Upload File">

    </form>

</cfif>

It worked as expected. The text file was duly uploaded to the directory, c:\uploads.

I used the default settings of Coldfusion 11 Update 2, including the built-in Tomcat web server. I am also on Windows 7 Ultimate.

tommuck1
tommuck1Author
Inspiring
November 19, 2014

Weird, I just used your code directly and my file does not get saved. If I try it with a file named "test.txt" it saves perfectly. I'm on CF8 under Jrun, wonder if there is a difference. On Windows 7 also.

BKBK
Community Expert
Community Expert
November 19, 2014

Do you get an error message?