Download JPG’s with ColdFusion from a Linux server

July 7th, 2006 英文

与Flex和Coldfusion案卷upload/下载component操作时我碰到一些好玩的Linux 和Windows file format的问题。Upload一些案卷没问题但是,除非你使用Coldfusion的缺省charset tag, Linux服务器的JPG就办不动。

XML:
  1. <cffile action="read"
  2.     file="#folder#/#filename#" variable="fileData"/>
  3.     <cfcatch>
  4.         <cflog text="Invalid read #folder#/#filename#">
  5.     </cfcatch>
  6. </cftry>
  7. <cfif fileData NEQ ""><cfcontent reset="yes"><cfoutput>#fileData#</cfoutput></cfif>

用上述的代码会使JPG"不能用"。在tag内你必须设定"charset"。下面的代码有效。

XML:
  1. <cffile action="read" charset="iso-8859-1"
  2.     file="#folder#/#filename#" variable="fileData"/>
  3.     <cfcatch>
  4.         <cflog text="Invalid read #folder#/#filename#">
  5.     </cfcatch>
  6. </cftry>
  7. <cfif fileData NEQ ""><cfcontent reset="yes"><cfoutput>#fileData#</cfoutput></cfif>

依靠服务器的缺省, 我认为还有别的办法。所以当你想从Linux 服务器,用ColdFusion下载二进制案卷时,要小心charset的问题。

Entry Filed under: ColdFusion MX 7

2 Comments Add your own

  • 1. Cédric  |  July 17th, 2006 at 9:48 am

    Hello,

    I’ve the same problem. When I upload a document (word, excel, …), the files seems to be uploaded correctly. But when I try to download it (using cffile tag), the file is corrupted (invalid charset I think).

    Can you help me . Do you have found any solution ?

    Thanks,
    Ced

  • 2. Renaun Erickson  |  July 17th, 2006 at 9:52 am

    <cffile action=”read” charset=”iso-8859-1″ …

    Worked for me, here is a list of all the valid charsets try them all:

    * utf-8
    * iso-8859-1
    * windows-1252
    * us-ascii
    * shift_jis
    * iso-2022-jp
    * euc-jp
    * euc-kr
    * big5
    * euc-cn
    * utf-16

    http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000250.htm

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


About: I work as a Platform Evangelist for Adobe Systems Incorporated.

My Amazon.com Wish List

Calendar

July 2006
S M T W T F S
« Jun   Aug »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Most Recent Posts


Flex.org - The Directory for Flex