如何解决如何在 Chrome 上的文件夹中打开电子邮件
有一个共享公用文件夹,用户可以使用它来上传共享文档。在共享资源中,部分用户上传了outlook邮件快捷方式,供自己共享。
当用户尝试在 chrome、IE 等上打开资源时,我试图让这封电子邮件在 Outlook 中打开。
这能实现吗?
以下代码是我目前正在做的,目的是让用户能够在浏览器上查看文件夹并打开和保存文档:
<!--- The following if statement checks if the url wants to be downloaded. If it does,it creates a downloadable link. --->
<cfif structKeyExists(URL,'method') and URL.method eq 'download'>
<cfset file_name = URL.name />
<cfset path = URL.path />
<!--- The following if statements determine file type. --->
<cfif findNoCase('.doc',file_name) or findNoCase('.odt',file_name) or findNoCase('.rtf',file_name) >
<cfset file_type = 'application/msword' >
<cfelseif findNoCase('.pdf',file_name) >
<cfset file_type = 'application/pdf' >
<cfelseif findNoCase('.xls',file_name) or findNoCase('.xlt',file_name) or findNoCase('.csv',file_name)>
<cfset file_type = 'application/vnd.ms-excel' >
<cfelseif findNoCase('.tif',file_name) >
<cfset file_type = 'image' >
<cfelseif findNoCase('.jpg',file_name) >
<cfset file_type = 'image/jpeg' >
<cfelseif findNoCase('.url',file_name) or findNoCase('.lnk',file_name) >
<cfset file_type = 'text/uri-list' >
<cfelseif findNoCase('.msg',file_name) >
<cfset file_type = 'text/uri-list' >
</cfif>
<!--- The following statements creates a downloadable link of the file. This is done by using cfheader and cfcontent --->
<cfheader name="Content-disposition" value="inline; filename=#file_name#">
<!---Check if file type is available. If available,show type. --->
<cfif isDefined("file_type") >
<cfcontent type="#file_type#" file="#path#\#file_name#">
<!--- If file type is not found,display file anyways. --->
<cfelse>
<cfcontent file="#path#\#file_name#">
</cfif>
<cfabort>
</cfif>
解决方法
This document 描述 <cfcontent>
标记声明,“以下标记可以强制大多数浏览器显示一个对话框,询问用户是否要保存由cfcontent 标签使用文件名值指定的文件名。如果用户选择打开文件,大多数浏览器会在相关应用程序中打开文件,而不是浏览器窗口。
<cfheader name="Content-Disposition" value="attachment; filename=filename.ext">
某些文件类型,例如 PDF 文档,不使用可执行代码,可以直接在大多数浏览器中显示。要请求浏览器直接显示文件,请使用类似于以下内容的 cfheader 标记:
<cfheader name="Content-Disposition" value="inline; filename=name.ext">"
您问题中的代码是这样的:
<cfheader name="Content-Disposition" value="inline; filename=#file_name#">
关键属性是值。您有“内联”,它要求浏览器直接显示文件。 “附件”值将允许用户使用本地计算机上该类型文件的默认应用程序打开文件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。