将文件上传到 ColdFusion 中的数据库
我只是想使用 ColdFusion 将文件上传到我的数据库。我了解如何将图像上传到目录,但我想将其直接放入数据库中。
我已将数据库字段设置为 varbinary(MAX) 以接受图像并让存储过程插入它。目前,我将图像上传到文件系统的代码是:
<cfif isdefined("form.FileUploadImage")>
<cffile action="upload" filefield="FileUploadImage" destination="#uploadfolder#" nameconflict="overwrite" accept="image/*" >
</cfif>
我显然遗漏了一些支持代码,但实际上我需要做的就是获取存储在内存中的文件的二进制表示,而不是文件系统。
有专家可以帮忙吗?
谢谢, 乔治
I simply would like to upload a file to my database using ColdFusion. I understand how to upload an image to a directory, but I would like to place it directly in the database.
I have set a database field to varbinary(MAX) to accept the image and have the stored procedure to insert it. Currently my code for uploading the image to my file system is:
<cfif isdefined("form.FileUploadImage")>
<cffile action="upload" filefield="FileUploadImage" destination="#uploadfolder#" nameconflict="overwrite" accept="image/*" >
</cfif>
I've obviously left some of the supporting code out, but really all I need to do is get a binary representation of the file stored in memory, instead of the file system.
Any experts out there that can help?
Thanks,
George
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西吗?
稍后,如果您想将图像流式传输回浏览器,请使用
(CF8+)Something like this?
Later if you want to stream the image back to the browser, use
<cfimage>
(CF8+)绕过将文件保存到文件系统的方法:
The way to bypass saving file to the file system: