Coldfusion 拒绝解码 Base64 图像
几个小时前,我发现我可以通过表单属性传递文件api创建的DataUrl,轻松地在html5文件api和coldfusion之间进行通信,并让coldfusion为我将图像文件写入服务器。
这很好用。
然而现在,它拒绝解码我传递的这些 Base64 字符串。我已经在其他解码器中测试了 Base64 字符串,它们可以正确显示图像。我没有对代码进行任何更改。那么谁能告诉我这里发生了什么事..?
<cfimage source="#attributes.image#" action="write" destination="../images/new_image.png" isBase64="yes" overwrite="true">
2012 年 20 月编辑: 今天,当我在工作中打开计算机时,它又开始工作了。我仍然不清楚昨天发生了什么。 Coldfusion 返回的错误是:“该文件似乎不是 base64 编码的”,这绝对是,我检查了不止一次。我传递给 cfimage 标记的 base64 字符串包含标头,就像您所描述的那样。
A couple of hours ago I found that I could easily communicate between the html5 file api and coldfusion by passing along the DataUrl created by the file api through form attributes and let coldfusion write the image file for me to the server.
This worked fine.
Now however, it refuses to decode these base64 strings I'm passing along. I've already tested the base64 strings in other decoders and they display the image correctly. I haven't changed anything to the code. So can anyone please tell me what's going on here..?
<cfimage source="#attributes.image#" action="write" destination="../images/new_image.png" isBase64="yes" overwrite="true">
edit 20/12:
Today it started working again when I turned on my computer at work. It is still not clear to me what happened yesterday. The error Coldfusion returned was: 'the file does not appear to be base64-encoded', which it absolutely was, I checked more than once. The base64-string I passed to the cfimage tag contained headers just like you described.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您所做的只是按原样保存,则可以跳过
标记并使用
标记。
会增加大量开销,并且仅当您计划在保存图像之前修改图像时才有用。例如。
或者尝试...
您的 base64 字符串有标头吗?
例如。
"data:image/jpg;base64,..."
在字符串的开头?从内存来看,imageReadBase64() 支持带头和不带头的 Base64 字符串。
http://www.cfquickdocs.com/cf9/#BinaryDecode
http://www.cfquickdocs.com/cf9/#ImageReadBase64
You could skip the
<cfimage>
tag and use a<cffile>
tag if all you are doing is saving it exactly as is.<cfimage>
adds a bunch of overhead and is only useful if you plan to modify the image before saving it.Eg.
Alternatively try...
Does your base64 string have headers?
eg.
"data:image/jpg;base64,..."
at the start of the string?From memory, imageReadBase64() supports base64 strings with and without headers.
http://www.cfquickdocs.com/cf9/#BinaryDecode
http://www.cfquickdocs.com/cf9/#ImageReadBase64