Download JPG’s with ColdFusion from a Linux server
[lang_en]
I am working on a Flex and ColdFusion file upload/download component and came across the fun Linux and Windows file format issues. The files will upload correctly but if you try and pull down a JPG file form the linux server with ColdFusion’s
file="#folder#/#filename#" variable="fileData"/>
<cfcatch>
<cflog text="Invalid read #folder#/#filename#">
</cfcatch>
</cftry>
<cfif fileData NEQ ""><cfcontent reset="yes"><cfoutput>#fileData#</cfoutput></cfif>
For JPG’s the code above will write the file as strange charactors and cause the JPG be unusable. You must set the “charset” attribute in the
file="#folder#/#filename#" variable="fileData"/>
<cfcatch>
<cflog text="Invalid read #folder#/#filename#">
</cfcatch>
</cftry>
<cfif fileData NEQ ""><cfcontent reset="yes"><cfoutput>#fileData#</cfoutput></cfif>
I assume it could even be another value depending on on the server’s default values. So just beware of the charset value issues when downloading binary files with ColdFusion from linux servers.
[/lang_en]
[lang_zh]
与Flexå’ŒColdfusion案å·upload/下载componentæ“作时我碰到一些好玩的Linux å’ŒWindows file format的问题。Upload一些案å·æ²¡é—®é¢˜ä½†æ˜¯,除éžä½ 使用Coldfusion的缺çœcharset tag, LinuxæœåŠ¡å™¨çš„JPG就办ä¸åŠ¨ã€‚
file="#folder#/#filename#" variable="fileData"/>
<cfcatch>
<cflog text="Invalid read #folder#/#filename#">
</cfcatch>
</cftry>
<cfif fileData NEQ ""><cfcontent reset="yes"><cfoutput>#fileData#</cfoutput></cfif>
用上述的代ç 会使JPG”ä¸èƒ½ç”¨”。在tagå†…ä½ å¿…é¡»è®¾å®š”charset”。下é¢çš„代ç 有效。
file="#folder#/#filename#" variable="fileData"/>
<cfcatch>
<cflog text="Invalid read #folder#/#filename#">
</cfcatch>
</cftry>
<cfif fileData NEQ ""><cfcontent reset="yes"><cfoutput>#fileData#</cfoutput></cfif>
ä¾é æœåŠ¡å™¨çš„缺çœ, æˆ‘è®¤ä¸ºè¿˜æœ‰åˆ«çš„åŠžæ³•ã€‚æ‰€ä»¥å½“ä½ æƒ³ä»ŽLinux æœåŠ¡å™¨,用ColdFusion下载二进制案å·æ—¶,è¦å°å¿ƒcharset的问题。
[/lang_zh]