Showing a error Message for FileUpload

  • Nico

    8 days ago

    I tryed this (validateFile is a custom action the ai told me to create) but i dont know how to "access" the data form this custom action in the switch step..

    custom action is:

    function validateFile (args, ctx) {
    function validateFile({file}, ctx) { if (file) { if (file.size > 2000000) { ctx.triggerActionEvent("error", "Datei ist größer als 2MB"); } else if (!file.type.match('image/jpeg|image/png')) { ctx.triggerActionEvent("error", "Nur Bild-Datein erlaubt"); } else { ctx.triggerActionEvent("success", "Datei hat einen Fehler"); } } }

    }
  • Nico

    8 days ago

    i dont really know if this custom action is even needed or the input field itself gives me a state back based on the limitions i introduced with the attributes "filetype and filesize"
  • Lucas G

    8 days ago

    Assign the file type directly to the input field. There’s no need for JS for file type restrictions
  • Then your custom action only needs to check file size

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.