Skip to main content
Participant
December 6, 2017
Answered

CF2016 - FileUpload() - Malformed input or input contains unmappable characters

  • December 6, 2017
  • 2 replies
  • 2122 views

The FileUpload() and <cffile> method throw an error if you upload files with special characters like "öäu".

Everything is set to UTF-8. With ColdFusion 11 we did not have this problem.

Does anybody has any idea?

Regards

Andy

    This topic has been closed for replies.
    Correct answer Charlie Arehart

    Someone else may have a better answer for you, but in the meantime, I have some questions that may help us help you.

    First, are the special characters in the name? or in the file content?

    Second, you can override the name of the file with the DESTINATION attribute on a CFFILE action=”upload” (it may appear to most that the destination names only a folder, but it can be a folder or a folder/filename). If you do that, and name it to a different name (even a temp one), might you then be able to do a cffile action=”rename”? I realize that’s a hack. Just trying to help you narrow where the problem is, if not offer a short-term work-around.

    Finally, you seem to be implying that this is a change in CF2016 that is affecting you. If you have the CF11 around still, you may want to start by comparing all the CF Admin settings in your CF11 setup to CF2016. Maybe you had a setting that you forgot to bring forward. Or maybe you put in some JVM argument (in the “java and jvm” page) which influenced the difference you see.

    (Even better, if you still have CF11 around, can you confirm 100% that the same file uploaded from the same page to the same action page does work and not get this error? It may be that something “like this” did used to work for you, but perhaps this is just different enough to not work now.)

    Again, just trying to help, not antagonize or burden you.

    /charlie

    2 replies

    BontheAuthor
    Participant
    December 6, 2017

    Dear Charlie,

    thanks for your help and the right hint.

    We are overriding the filename with a UUID now with the DESTINATION attribute. That solution works perfectly for us.

    The JVM arguments and the CF Admin settings are the same. That was the first thing we compared. It seems to be a bug in CF16, I guess.

    You saved my day!

    Andy

    BKBK
    Community Expert
    Community Expert
    December 7, 2017

    The use-case you describe works just fine in a test. I created a text file and named it öäu.txt. Then I used the following code to upload it:

    <cfif isDefined("form.fieldnames") >

        <cffile action = "upload"

            fileField = "fileContents"

            destination = "c:\uploads"

            nameConflict = "makeunique">

          

    <cfelse>

        <form method="post" action="uploadForm.cfm" enctype="multipart/form-data">

            <input name="fileContents" type="file">

            <br>

            <input name="submit" type="submit" value="Upload File">

        </form>

    </cfif>

    The file was duly uploaded to c:\uploads\öäu.txt.

    My system consists of:

    ColdFusion 2016, Build 5

    Windows 7 Ultimate

    BontheAuthor
    Participant
    December 7, 2017

    We are running Cold Fusion 2016 on Linux. Maybe that matters.

    Charlie Arehart
    Community Expert
    Charlie ArehartCommunity ExpertCorrect answer
    Community Expert
    December 6, 2017

    Someone else may have a better answer for you, but in the meantime, I have some questions that may help us help you.

    First, are the special characters in the name? or in the file content?

    Second, you can override the name of the file with the DESTINATION attribute on a CFFILE action=”upload” (it may appear to most that the destination names only a folder, but it can be a folder or a folder/filename). If you do that, and name it to a different name (even a temp one), might you then be able to do a cffile action=”rename”? I realize that’s a hack. Just trying to help you narrow where the problem is, if not offer a short-term work-around.

    Finally, you seem to be implying that this is a change in CF2016 that is affecting you. If you have the CF11 around still, you may want to start by comparing all the CF Admin settings in your CF11 setup to CF2016. Maybe you had a setting that you forgot to bring forward. Or maybe you put in some JVM argument (in the “java and jvm” page) which influenced the difference you see.

    (Even better, if you still have CF11 around, can you confirm 100% that the same file uploaded from the same page to the same action page does work and not get this error? It may be that something “like this” did used to work for you, but perhaps this is just different enough to not work now.)

    Again, just trying to help, not antagonize or burden you.

    /charlie

    /Charlie (troubleshooter, carehart. org)