The file could not be loaded. Reason: The file extension does not match its underlying type.

Certified Associate Developer
Hi! 
I'm working on version 24.3 with Spanish as the primary language, and I've added a document upload component (a!fileUploadField) to an interface with validation to receive only an XLSX document. I used a file originally with an .xlsx extension and it validates well, but if I manually change the extension to .pdf so it converts, for example, and then upload it, I get an error that I didn't capture in my validation: "File could not be uploaded. Reason: The file extension does not match its underlying file type."
It doesn't actually upload the document, and the error persists even without the attached document. Or if I upload another correct document, I have to refresh the entire page for it to stop appearing.
Is there a way to bypass this validation and just leave the one I have manually, or is there a way to update the validation when a new document is uploaded?


In this part of code, local!excel is not a refresh variable, is just:

localVariables(
local!excel,
...
)


  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Associate Developer
    in reply to Shubham Aware

    From my local desktop, what I do is create a new Excel file, which creates an empty document with an .xlsx extension (for example: test.xlsx):

    • If I attach it like this, everything is fine.
    • If I edit the name from the desktop using Windows Explorer and change the .xlsx to .pdf (or any other extension, I can also use .png; it's just to use the same file by manually changing its extension), the new name would be test.pdf, but it's the same file. So when I upload this same file with its new extension, I get that error message that I don't want, and I have to refresh the page and start over.
    • If I create a new file test2.pdf or any other extension and attach it, the message about my validation appears, not the one in the photo I showed in my question, which is also correct.
  • 0
    Certified Lead Developer
    in reply to Eleeeena1204

    Changing a file extension manually does not alter the actual file content, so Appian blocks uploads when the extension and content don’t match. You cannot upload such files in Appian.

  • 0
    Certified Associate Developer
    in reply to Shubham Aware
    Yes, that's correct, Appian shouldn't allow it. What happens is that the error message doesn't go away even when uploading a correct file. This disables the form and forces the user to refresh the entire page and start over. It's fine that the message may appear, but it shouldn't persist when uploading another correct file.
  • 0
    Certified Lead Developer
    in reply to Eleeeena1204

    Once you upload the correct file, the message should disappear. Make sure you are uploading the document to the same variable that is used in both the value and saveInto parameters.

  • 0
    Certified Lead Developer
    in reply to Shubham Aware

    There's a longstanding and known bug where, for instance, if a user tries to upload a document that's actually empty (which Appian disallows), that then even after they clear that upload and try uploading a valid file, the error message still (incorrectly) persists.  It sounds like, if what Eleeeeeeeeena is saying here is true, a similar (incorrect) behavior might be persisting on the "document type mismatch" error, which I haven't confirmed (or tested) for myself, but would not surprise me whatsoever.