0

我正在尝试在 CF11 服务器上使用 cfscript 上传文件
但每次上传文件时都会拒绝 mime 类型。示例错误:“服务器不接受上传文件 text/plain 的 MIME 类型或扩展名。”

关于 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 );
    }
}
4

1 回答 1

0

愚蠢的错误。我需要将此行调整为: allowed_mimetypes = ArrayToList(mime_arr, ',');

于 2017-10-09T01:03:28.707 回答