CFFILE action="upload" accept="text/plain" 时允许批处理文件
CFFILE action="upload" allows for batch files when accept="text/plain"
从 ColdFusion 9 升级到 ColdFusion 2016 时,我们允许用户上传文件的功能用于阻止 .bat
文件、.cert
文件等,但是在 ColdFusion 2016 中相同的代码允许上传这些文件。
There were several changes to cffile action="upload" in ColdFusion 10
on how it handles what file types are allowed.
Also new in ColdFusion 10 is the strict attribute which defaults to
true.
With strict set to true, the mime type of the file is checked when the
file upload occurs; however, this means that ACCEPT must be a list of
mime types and not file extensions.
<cffile action="UPLOAD" filefield="form.filename"
destination="#change_path#" accept="text/plain" strict="true">
无论我是否明确将 strict 设置为 true,.bat
文件仍会在 ColdFusion 2016 中上传。
是否有特定于 ColdFusion 管理员的设置已更改或我可以修改以禁止那些不需要的文件类型?
使用"strict"时,不检查文件扩展名。成功上传后,您需要添加一个单独的例程来根据文件扩展名进行阻止。过去,我遇到过 different/incorrect mimetypes 阻止有效内容上传的问题。 (有时 Mac/Safari 用户会使用正确但不同于配置的 mime 类型上传文件。)
<CFIF ListFindNoCase("bat", CFFile.serverFileExt)>
<!--- delete file, throw error, display message, etc --->
<CFELSEIF CFFile.serverFileExt IS "JPEG">
<!--- rename file to JPG --->
</CFIF>
我们还为文件上传添加了一个例程,以从 Mac 用户可能添加的文件名中删除非法或非标准字符。
对于图像,我们还将所有 JPEG 文件重命名为 JPG。我们还使用 GraphicsMagick(命令行;比 CFImage w/broader 图像兼容性更快)将 JPG 色彩空间重置为 RGB。 (ColdFusion 图像和 PDF 生成功能最适合此类图像,并且在尝试读取图像时不会抛出错误。)
从 ColdFusion 9 升级到 ColdFusion 2016 时,我们允许用户上传文件的功能用于阻止 .bat
文件、.cert
文件等,但是在 ColdFusion 2016 中相同的代码允许上传这些文件。
There were several changes to cffile action="upload" in ColdFusion 10 on how it handles what file types are allowed.
Also new in ColdFusion 10 is the strict attribute which defaults to true.
With strict set to true, the mime type of the file is checked when the file upload occurs; however, this means that ACCEPT must be a list of mime types and not file extensions.
<cffile action="UPLOAD" filefield="form.filename"
destination="#change_path#" accept="text/plain" strict="true">
无论我是否明确将 strict 设置为 true,.bat
文件仍会在 ColdFusion 2016 中上传。
是否有特定于 ColdFusion 管理员的设置已更改或我可以修改以禁止那些不需要的文件类型?
使用"strict"时,不检查文件扩展名。成功上传后,您需要添加一个单独的例程来根据文件扩展名进行阻止。过去,我遇到过 different/incorrect mimetypes 阻止有效内容上传的问题。 (有时 Mac/Safari 用户会使用正确但不同于配置的 mime 类型上传文件。)
<CFIF ListFindNoCase("bat", CFFile.serverFileExt)>
<!--- delete file, throw error, display message, etc --->
<CFELSEIF CFFile.serverFileExt IS "JPEG">
<!--- rename file to JPG --->
</CFIF>
我们还为文件上传添加了一个例程,以从 Mac 用户可能添加的文件名中删除非法或非标准字符。
对于图像,我们还将所有 JPEG 文件重命名为 JPG。我们还使用 GraphicsMagick(命令行;比 CFImage w/broader 图像兼容性更快)将 JPG 色彩空间重置为 RGB。 (ColdFusion 图像和 PDF 生成功能最适合此类图像,并且在尝试读取图像时不会抛出错误。)