6 Replies Latest reply on Nov 20, 2014 12:51 PM by BKBK

    unicode file upload

    tommuck1 Level 1

      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">


      <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?

        • 1. Re: unicode file upload
          BKBK Adobe Community Professional & MVP

          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,



          <cfif isDefined("Form.FileContents") >


              <cffile action = "upload"

                  fileField = "FileContents"

                  destination = "c:\uploads"




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


              <cfcatch type="any">

                  <cfdump var="#cfcatch#">




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

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


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




          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.

          • 2. Re: unicode file upload
            tommuck1 Level 1

            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.

            • 3. Re: unicode file upload
              BKBK Adobe Community Professional & MVP

              Do you get an error message?

              • 4. Re: unicode file upload
                tommuck1 Level 1

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

                • 5. Re: unicode file upload
                  tommuck1 Level 1

                  cffile struct shows this after upload:


                  ATTEMPTEDSERVERFILE???????? ?.txt
                  CLIENTDIRECTORY???????? ?.txt
                  CLIENTFILE???????? ?.txt
                  CLIENTFILENAME???????? ?
                  DATELASTACCESSED{d '1969-12-31'}
                  SERVERFILE???????? ?.txt
                  SERVERFILENAME???????? ?
                  TIMECREATED{ts '1969-12-31 19:00:00'}
                  TIMELASTMODIFIED{ts '1969-12-31 19:00:00'}
                  • 6. Re: unicode file upload
                    BKBK Adobe Community Professional & MVP

                    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.