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?
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.
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.
Copy link to clipboard
Copied
Do you get an error message?
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.
Copy link to clipboard
Copied
cffile struct shows this after upload:
ATTEMPTEDSERVERFILE | ???????? ?.txt |
CLIENTDIRECTORY | ???????? ?.txt |
CLIENTFILE | ???????? ?.txt |
CLIENTFILEEXT | txt |
CLIENTFILENAME | ???????? ? |
CONTENTSUBTYPE | plain |
CONTENTTYPE | text |
DATELASTACCESSED | {d '1969-12-31'} |
FILEEXISTED | NO |
FILESIZE | 0 |
FILEWASAPPENDED | NO |
FILEWASOVERWRITTEN | NO |
FILEWASRENAMED | NO |
FILEWASSAVED | NO |
OLDFILESIZE | 0 |
SERVERDIRECTORY | d:\websites\uploads\Attachments |
SERVERFILE | ???????? ?.txt |
SERVERFILEEXT | txt |
SERVERFILENAME | ???????? ? |
TIMECREATED | {ts '1969-12-31 19:00:00'} |
TIMELASTMODIFIED | {ts '1969-12-31 19:00:00'} |
Copy link to clipboard
Copied
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.