Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • GTona 6 posts 76 karma points
    Jul 24, 2018 @ 15:08
    GTona
    0

    FileUpload filed max size

    Hi everybody, is ther any way to limit file upload size without acting at web.config level? I mean is it there the possibility to evntually extend componet in order to block user upload when a certain size is reached or intecept upload and generate an error?

    Thanks for kind answer

  • Aaron Yarborough 2 posts 74 karma points
    Jul 24, 2018 @ 15:16
    Aaron Yarborough
    0

    The HttpPostedFileBase class has a property named ContentLength which can be used to determine file size.

    More on HttpPostedFileBase here: https://msdn.microsoft.com/en-us/library/system.web.httppostedfilebase(v=vs.110).aspx

    public ActionResult Upload(HttpPostedFileBase file)
    {
        if (file.ContentLength < 1024)
        {
            // File is too large 
            ...
        }
    }
    
  • GTona 6 posts 76 karma points
    Jul 24, 2018 @ 15:22
    GTona
    0

    Thanks Aaron for you flesh answer. You are right, but how can I apply this approach to Umbraco From FileUpload field? Maybe my question is silly, but I don't know how to do it.

    Thanks again

  • [email protected] 378 posts 1915 karma points MVP 4x c-trib
    Jul 25, 2018 @ 06:12
    jeffrey@umarketingsuite.com
    0

    Hi GTona,

    we've created a package which does exactly this: https://our.umbraco.com/projects/backoffice-extensions/umbraco-forms-on-perplex-steroids/.

    Kind regards, Jeffrey

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies