in reply to Re: File Upload Size Check
in thread File Upload Size Check

Yes it should be what you suggested. However when i am trying to upload the file greater than 5MB size,it is throwing some error.

Replies are listed 'Best First'.
Re^3: File Upload Size Check
by haukex (Archbishop) on Aug 05, 2019 at 12:51 UTC
      Suppose if I set the file size 1 MB in script and when I am trying to upload the file greater than 1 MB,it is throwing error "Failed to execute CGI "/cgi-bin/Maintenance_Framework.cgi". Contact your administrator." In my view,it should display that "File is too big for upload".

        From the documentation I linked to:

        If CGI.pm detects a POST that is greater than the ceiling, it will immediately exit with an error message.

        The code you posted displays an upload too large error on the condition:

        if ( !$filename ) { ....
        "Failed to execute CGI "/cgi-bin/Maintenance_Framework.cgi". Contact your administrator."

        That sounds like a message from the web server, not from Perl, so you should check your server's error logs for the message that Perl is giving you. See also CGI Help Guide and Troubleshooting Perl CGI scripts.

Re^3: File Upload Size Check
by marto (Cardinal) on Aug 05, 2019 at 12:33 UTC

    Your code posted has a limit of 1MB. If you want a 5MB limit set it to what I showed you, if you want to upload something bigger, change the multiplier. Also ensure your web server isn't configured to limit file uploads.