Set file upload restrictions in Zoho Creator

Set file upload restrictions in Zoho Creator

Hey Creators,

Welcome to the next post in the Creator Simplified series.


Today, we’ll explore how to implement file upload restrictions to limit user submissions to specific file types. By implementing an allowed list for file uploads, you can optimize the data you collect and prevent complications arising from multiple formats. This proactive approach not only enhances data integrity but also improves the overall user experience.

 

Use Case: Fuel Reimbursement with File Uploads


Imagine a fuel reimbursement form that allows employees to upload receipts for their fuel expenses. To maintain consistency and ensure only relevant file types are submitted, you can restrict uploads to just PDF and PNG formats.

 

Setting Allowed File Types:
  1. if(input.File_upload != "") // Check if the file upload field is not empty
  2. {
  3. allowed_list = {"pdf","png"}; // List of allowed file extensions
  4. // Get the file extension by splitting the filename
  5. splitList = input.File_upload.toList("."); // Split the uploaded file name by periods (.)
  6. ext = splitList.get(splitList.size() - 1).toLowerCase();
  7. // Get the file extension (last element of the list) and convert it to lowercase
  8. if(!allowed_list.contains(ext)) // Check if the extension is NOT in the allowed list
  9. {
  10. alert "This file type is not accepted."; // Show alert message
  11. cancel submit; // Prevent form submission
  12. }
  13. }


Demo:



In this example, when a user uploads a file, the script checks the file extension against the allowed list. If the uploaded file is not a PDF or PNG, an alert is displayed, and the form submission is cancelled. This workflow is triggered during the form submission validation, ensuring only acceptable file types are submitted. This approach helps maintain data integrity and enhances the user experience by providing clear feedback on acceptable file types.

 

That’s it for today! If you have any questions or your own tips to share, drop them in the comments below. Stay tuned for more insights in our Creator Simplified series!

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方