• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

unicode file upload

Explorer ,
Nov 19, 2014 Nov 19, 2014

Copy link to clipboard

Copied

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?

Views

522

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 19, 2014 Nov 19, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 19, 2014 Nov 19, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 19, 2014 Nov 19, 2014

Copy link to clipboard

Copied

Do you get an error message?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 19, 2014 Nov 19, 2014

Copy link to clipboard

Copied

No errors, file was not saved, "filewassaved" attribute shows false, so did not see the message. Maybe it's an Apache setting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 20, 2014 Nov 20, 2014

Copy link to clipboard

Copied

cffile struct shows this after upload:

ATTEMPTEDSERVERFILE???????? ?.txt
CLIENTDIRECTORY???????? ?.txt
CLIENTFILE???????? ?.txt
CLIENTFILEEXTtxt
CLIENTFILENAME???????? ?
CONTENTSUBTYPEplain
CONTENTTYPEtext
DATELASTACCESSED{d '1969-12-31'}
FILEEXISTEDNO
FILESIZE0
FILEWASAPPENDEDNO
FILEWASOVERWRITTENNO
FILEWASRENAMEDNO
FILEWASSAVEDNO
OLDFILESIZE0
SERVERDIRECTORYd:\websites\uploads\Attachments
SERVERFILE???????? ?.txt
SERVERFILEEXTtxt
SERVERFILENAME???????? ?
TIMECREATED{ts '1969-12-31 19:00:00'}
TIMELASTMODIFIED{ts '1969-12-31 19:00:00'}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2014 Nov 20, 2014

Copy link to clipboard

Copied

LATEST

You are on Coldfusion 9 and JRun whereas I am on ColdFusion 11 and Tomcat. The two systems are so different that it is futile for us to compare notes.

Nevertheless, the default encoding in both Coldfusion versions is UTF-8. Taking that as an assumption, you could check JRun's settings - jrun.xml or jrun-web.xml - to see if you can configure the encoding there. Just a stab in the dark.

Whatever you do, back up the file jrun.xml or jrun-web.xml beforehand. Search the file for the word, encoding, and, where appropriate, set the encoding to UTF-8. Restart Coldfusion afterwards.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation