小编Sun*_*Ham的帖子

coldfusion如何在数据库中保存pdf文件并在浏览器中获取它

插入MS-SQL 2008数据库

<cffile action="READBINARY" file="#form.FileContents#" variable="binPDF">
<cfquery name="Uploaded" datasource="#cfbasedatasource#">
INSERT INTO UploadedFiles
    (
    AccountId,
    Filecontent
    )
VALUES
    (
    '#UrlAccountId#',
    <cfqueryparam value='#binPDF#' cfsqltype='cf_sql_blob'>
    )
</cfquery>
Run Code Online (Sandbox Code Playgroud)

=========================这是从数据库显示到浏览器:

<cfset binaryData = #cfGetfilecontentquery.Filecontent[1]#>
<cfheader name="Content-Disposition" value="inline; filename=testDocument.pdf">
<cfcontent variable="#binarydata#" type="application/pdf" reset="yes" />
Run Code Online (Sandbox Code Playgroud)

但我只能在浏览器中看到"无法加载PDF文档"

database pdf coldfusion cffile

2
推荐指数
1
解决办法
2077
查看次数

标签 统计

cffile ×1

coldfusion ×1

database ×1

pdf ×1