将blob图片保存到数据库而不存储到高清

发布于 2024-12-29 20:38:06 字数 575 浏览 2 评论 0原文

我在 Coldfusion 中有一个 Base64 图片字符串。

如何将此图像 blob 保存到数据库中而不存储到文件磁盘? 我的职能。

<cfset base64string="base64picturestring">
<cfimage source="#ImageReadBase64("data:image/png;base64,#base64string#")#"
destination="c:\picture.png" action="write" overwrite="true">
<cffile action="readbinary" file="c:\picture.png" variable="ImageData"/>

INSERT INTO imagedb (imageblob)
VALUES (<cfqueryparam cfsqltype="cf_sql_blob" value="#ImageData#" />)

但我不想将图像保存在硬盘上。 我需要这个。

base64----imageblob----database

有帮助吗?

I have an base64 picture string in coldfusion.

How can I save this image blob into the database without storing to filedisk?
My function.

<cfset base64string="base64picturestring">
<cfimage source="#ImageReadBase64("data:image/png;base64,#base64string#")#"
destination="c:\picture.png" action="write" overwrite="true">
<cffile action="readbinary" file="c:\picture.png" variable="ImageData"/>

INSERT INTO imagedb (imageblob)
VALUES (<cfqueryparam cfsqltype="cf_sql_blob" value="#ImageData#" />)

But I don't want to save image on the hard drive.
I need this.

base64----imageblob----database

Any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

茶色山野 2025-01-05 20:38:06

您可以使用内存中的文件系统:

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSe9cbe5cf462523a0-70e2363b121825b20e7-8000.html#WSe9cbe5cf462523a0-540771bc12182683461-8000

<cfset base64string="base64picturestring">
<cfimage source="#ImageReadBase64("data:image/png;base64,#base64string#")#"
destination="ram://src/picture.png" action="write" overwrite="true">
<cffile action="readbinary" file="ram://src/picture.png" variable="ImageData"/>
<cffile action="delete" source = "ram://src/picture.png"> 

INSERT INTO imagedb (imageblob)
VALUES (<cfqueryparam cfsqltype="cf_sql_blob" value="#ImageData#" />)

You could use the in-memory filesystem:

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSe9cbe5cf462523a0-70e2363b121825b20e7-8000.html#WSe9cbe5cf462523a0-540771bc12182683461-8000

<cfset base64string="base64picturestring">
<cfimage source="#ImageReadBase64("data:image/png;base64,#base64string#")#"
destination="ram://src/picture.png" action="write" overwrite="true">
<cffile action="readbinary" file="ram://src/picture.png" variable="ImageData"/>
<cffile action="delete" source = "ram://src/picture.png"> 

INSERT INTO imagedb (imageblob)
VALUES (<cfqueryparam cfsqltype="cf_sql_blob" value="#ImageData#" />)
路还长,别太狂 2025-01-05 20:38:06
ToBinary('#yourString#')

计算 Base64 编码数据的二进制表示

ToBinary('#yourString#')

Calculates the binary representation of Base64-encoded data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文