【问题标题】:cfscript - uploading a filecfscript - 上传文件
【发布时间】:2017-10-08 23:29:28
【问题描述】:

我正在尝试在 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 );
    }
}

【问题讨论】:

    标签: cfml coldfusion-11 cffile


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 2015-12-26
      • 1970-01-01
      • 1970-01-01
      • 2013-12-19
      相关资源
      最近更新 更多