我试图在CF11服务器上使用cfscript上传文件
但每次上传文件时都会拒绝mime类型。
示例错误:
"服务器不接受MIME类型或上传文件text / plain的扩展名。"
关于ColdFusion的文档很少,更不用说ColdFusion脚本了。请帮忙。
以下是代码:
// define allowed file types
allowed_filetypes = {
txt="text/plain",
pdf="application/pdf",
doc="application/msword",
ppt="application/vnd.ms-powerpoint",
xls="application/vnd.ms-excel"
};
mime_arr = [];
for (key in allowed_filetypes
{
ArrayAppend(mime_arr, allowed_filetypes[key]);
}
allowed_mimetypes = '"' & ArrayToList(mime_arr, '","') & '"';
//upload file
if( structKeyExists( form, "thefile_input" )) {
allowed_extensions = lcase(StructKeyList(allowed_filetypes,","));
try {
uploadedFile = fileUpload( getTempDirectory(), "thefile_input", allowed_mimetypes, "MakeUnique" );
// move uploaded file to destination...
}
catch ( any e ){
writeOutput( e.message );
}
}
答案 0 :(得分:0)
allowed_mimetypes = ArrayToList(mime_arr, ',');