gpt4 book ai didi

coldfusion - ColdFusion 9 中文件上传的脚本函数

转载 作者:行者123 更新时间:2023-12-04 00:48:53 27 4
gpt4 key购买 nike

ColdFusion 9 中是否有与 cffile action="upload"等效的 cfscript?查看文档,似乎没有。

[更新] 这是在 9.0.1 更新中添加的
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSd160b5fdf5100e8f36f73035129d9e70a92-8000.html

最佳答案

您可以使用用户定义的函数轻松地抽象它。

<cffunction name="fileuploader">
<cfargument name="formfield" required="yes" hint="form field that contains the uploaded file">
<cfargument name="dest" required="yes" hint="folder to save file. relative to web root">
<cfargument name="conflict" required="no" type="string" default="MakeUnique">
<cfargument name="mimeTypesList" required="no" type="string" hint="mime types allowed to be uploaded" default="image/jpg,image/jpeg,image/gif,image/png,application/pdf,application/excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,image/pjpeg">

<cffile action="upload" fileField="#arguments.formField#" destination="#arguments.dest#" accept="#arguments.mimeTypesList#" nameConflict="#arguments.conflict#">

<cfreturn cffile>
</cffunction>

然后在 cfscript 中使用它:
<cfscript>
// NOTE: because of how cffile works, put the form field with the file in quotes.
result = fileUploader("FORM.myfield", myDestPath);
WriteOutput(result.fileWasSaved);
</cfscript>

注意:如果 Adob​​e 将来确实包含此功能,我会非常小心地重命名此功能。

关于coldfusion - ColdFusion 9 中文件上传的脚本函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2231289/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com