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

  • 0
    Certified Lead Developer

    This message appears because the PDF file type is blocked in the Admin Console under 'File Upload' using file extension blocking settings. The error will remain visible until the user manually refreshes or interacts with the interface; it does not clear automatically. One solution is to allow the file type at the admin level and then apply your own field-level validation in the interface(Make sure to create generic file upload to have consistency)

  • 0
    Certified Associate Developer
    in reply to Shubham Aware
    Hi! Thanks for your quick response, but I don't think that's the entire problem. If I upload a file that was originally a .pdf, it doesn't show this error, only my validation message. The problem lies in manually changing the file extension. If it was originally an .xlsx and I changed it to .pdf, it seems to become "corrupted" and the metadata doesn't match. It may have something to do with the administration, but I don't have access to it. However, .pdf files are accepted because they are attached elsewhere in the application. Thanks again. 
  • 0
    Certified Lead Developer
    in reply to Eleeeena1204

    How you are changing file extension?

  • 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.