Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

File Upload Validation

How to put a Validation on a file upload field so that the user could only upload images.

OriginalPostID-249057

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer
    @tanvirs , you can do something as below
    =======================================================
    a!formLayout(
    firstColumnContents: {
    a!fileUploadField(
    label: "Upload a File",
    labelPosition: "ABOVE",
    saveInto: ri!document,
    validations: {}
    )

    },
    secondColumncontents:{

    },
    buttons: a!buttonLayout(
    primaryButtons: a!buttonWidgetSubmit(
    label:"Submit",
    style: "PRIMARY"
    )
    ),
    validations:{
    if(
    or(
    find("jpg", a!fileUploadField(value: ri!document)),
    find("jpeg", a!fileUploadField(value: ri!document)),
    find("png", a!fileUploadField(value: ri!document)),
    find("ico", a!fileUploadField(value: ri!document)),
    find("gif", a!fileUploadField(value: ri!document)),
    find("bmp", a!fileUploadField(value: ri!document))
    )>0,"Invalid Format",{}

    )



    /* if(
    find("jpg", a!fileUploadField(value: ri!document))=0,{},
    "Invalid Format"
    )*/

    }
    )
    ==========================
    Hope this will help you
Reply
  • +1
    Certified Lead Developer
    @tanvirs , you can do something as below
    =======================================================
    a!formLayout(
    firstColumnContents: {
    a!fileUploadField(
    label: "Upload a File",
    labelPosition: "ABOVE",
    saveInto: ri!document,
    validations: {}
    )

    },
    secondColumncontents:{

    },
    buttons: a!buttonLayout(
    primaryButtons: a!buttonWidgetSubmit(
    label:"Submit",
    style: "PRIMARY"
    )
    ),
    validations:{
    if(
    or(
    find("jpg", a!fileUploadField(value: ri!document)),
    find("jpeg", a!fileUploadField(value: ri!document)),
    find("png", a!fileUploadField(value: ri!document)),
    find("ico", a!fileUploadField(value: ri!document)),
    find("gif", a!fileUploadField(value: ri!document)),
    find("bmp", a!fileUploadField(value: ri!document))
    )>0,"Invalid Format",{}

    )



    /* if(
    find("jpg", a!fileUploadField(value: ri!document))=0,{},
    "Invalid Format"
    )*/

    }
    )
    ==========================
    Hope this will help you
Children
No Data