更改Coldfusion上附件的文件名 [英] Change filename of attachments on Coldfusion
问题描述
我使用 cfmailparam
将文件附加到电子邮件。我从我的数据库获取文件名和路径。通常,附加文件具有唯一的名称,但是我可以通过查询数据库表中的以下列来获取原始文件名:
I'm using cfmailparam
to attach files to an email. I'm getting the filenames and paths from my database. Normally, the attached files have unique names, but I can get their original filenames by querying the following columns in a database table:
-
ASSET_FILE_NAME
:唯一名称 -
ASSET_REAL_NAME
:original_name_before_upload.pdf
ASSET_FILE_NAME
: unique nameASSET_REAL_NAME
: original_name_before_upload.pdf
当我使用cfmail发送电子邮件时,附件仍然使用唯一的名称,但我真的需要重命名它们。我已搜索并尝试过:
When I send the e-mail with cfmail, the attachments still use the unique names, but I really need to rename them. I've searched and tried also:
<cfloop from="1" to="#assetfiles.RecordCount#" index="i">
<cfmailparam
file="C:\files\#assetfiles.ASSET_FILE_NAME[i]#"
type="application/pdf"
disposition="attachment; filename=""#assetfiles.ASSET_REAL_NAME[i]#"""
/>
</cfloop>
但这不适用于所有附件文件。它只改变了1个文件名,其他的仍然使用唯一的名称。
But this is not working for all attachment files. It changes just 1 filename and the other ones still use the unique names.
有没有反正使这可能吗?
Is there anyway to make this possible?
推荐答案
有几种方法可以做到
- 您可以重命名文件本身
- 创建重复项,然后使用
remove =true
a href =https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-mo/cfmailparam.html =nofollow>cfmailparam
- 使用奇怪的名称读取文件,并附上新名称
< cfmailparam file =niceName.pdfcontent = #fileRead(oddName.pdf)#>
- You could rename the files themselves
- Create duplicates and then use the
remove="true"
attribute ofcfmailparam
- Read the files with the odd names and attach them with a new name
<cfmailparam file="niceName.pdf" content="#fileRead(oddName.pdf)#">
这篇关于更改Coldfusion上附件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!