从图像流式传输 cfcontent?
让我在顶部说,我不确定我是否真正理解 cfcontent 在做什么......所以如果这是一个愚蠢的问题,请耐心等待。
我一直在使用 cfcontent 将网络根目录之外的图像流式传输到浏览器。我决定现在要将图像存储在变量中,显示它,能够修改它,查看这些修改,并且仅在我确定我喜欢更改时才提交更改的变量。我想我可以使用 cfcontent 以某种方式从变量流式传输图像,然后从变量显示、修改、重新显示和保存该图像。我的原始代码很简单:
<img id="photoPlaceholder"
src="/#application.root_name#/administration/PhotoManagement/displayPhoto.cfm?thisImage=#thisImage#"
width="500px" />
并且 displayPhoto.cfm 组成:
<cfcontent type = "image/*"
file = "myPathName"
deleteFile = "No" />
我看到我可以将文件读入变量并从该变量进行流式传输:
<cffile action="readBinary" file="myPathName" variable="fileObject" />
<cfcontent type="image/*" variable="#fileObject#" />
但是如果我采取创建图像的中间步骤
<cfimage source="fileObject" name="myImage" />
<cfcontent type="image/*" variable="#myImage#" />
,那么我会收到属性验证错误。
有什么想法吗?
Let me just say at the top that I'm not sure I truly understand what cfcontent is doing... so bear with me if this is a stupid question.
I've been using cfcontent to stream images outside of my web root to the browser. I've decided that I now want to store the image in a variable, display it, have the ability to modify it, view those modifications, and only commit the changed variable when I'm sure I like the changes. I was thinking that I could use cfcontent to somehow stream the image from a variable, and then display, modify, re-display, and save that image from the variable. My original code was simply:
<img id="photoPlaceholder"
src="/#application.root_name#/administration/PhotoManagement/displayPhoto.cfm?thisImage=#thisImage#"
width="500px" />
and displayPhoto.cfm consisted of:
<cfcontent type = "image/*"
file = "myPathName"
deleteFile = "No" />
I see that I can read the file into a variable and stream from that variable:
<cffile action="readBinary" file="myPathName" variable="fileObject" />
<cfcontent type="image/*" variable="#fileObject#" />
but if I take the intermediate step of creating an image using
<cfimage source="fileObject" name="myImage" />
<cfcontent type="image/*" variable="#myImage#" />
then I get an attribute validation error.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ImageGetBlob()?
http://www.coldfusionjedi.com/index.cfm/2007/9/14/Serving-up-CFIMages-via-Image-Tags-and-a-NonCF-Friday-contest
如果您使用的是 CF9,您可以尝试先将映像写入
RAM://
驱动器,提供服务,然后从 RAM 中删除。ImageGetBlob()?
http://www.coldfusionjedi.com/index.cfm/2007/9/14/Serving-up-CFIMages-via-Image-Tags-and-a-NonCF-Friday-contest
If you're using CF9, you can try writing the image to the
RAM://
drive first, serve it, and delete from RAM.