0

I'm trying to upload a file using cfscript on a CF11 server
But every time I upload a file it rejects the mime type. Sample error: "The MIME type or the Extension of the uploaded file text/plain was not accepted by the server."

There is little documentation on ColdFusion, even less on ColdFusion script. Please help. .

Here's the code:

// 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 );
    }
}
Scotty
  • 130
  • 13

1 Answers1

0

stupid mistake. I needed to adjust this line to: allowed_mimetypes = ArrayToList(mime_arr, ',');

Scotty
  • 130
  • 13