我在Coldfusion9服务器上有一项服务,可以为我们即时创建图像横幅。一台单独的机器必须使用以下内容保存这些文件:
wget http://myserver.com/services/local/bannerCreator/250x250-v3.cfm?prodID=3&percentSaving=19问题是,我想不出如何让coldfusion在不使用临时文件的情况下写出二进制数据。此时图像只是显示为一个图像标记,如下所示:
<cfimage action = "writeToBrowser" source="#banner#" width="#banner.width#" height="#banner.height#" />有什么想法吗?或者我应该只使用临时文件?
发布于 2011-04-12 23:01:02
去掉height和width属性,并添加format属性:
<cfimage action = "writeToBrowser" source="#banner#" format="png" />wget应该允许重定向到CF在CFFileServlet文件夹中创建的物理文件,但是如果没有,可以设置一个标志,使其成为--max-redirect=10。
按照您的建议,临时文件也可以使用。只需写入文件并使用cfheader和cfcontent将其写出即可。只需确保临时文件名更加唯一即可。
<cfimage action="write" destination="tempfile.png" source="#banner#" format="png" />
<cfheader name="content-disposition" value="attachment; filename=banner.png" />
<cfcontent file="tempfile.png" deletefile="true" type="image/png" />https://stackoverflow.com/questions/5636874
复制相似问题