Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5987105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:46:02+00:00 2026-05-22T22:46:02+00:00

How should I go about handling http uploads that exceeds the post_max_size in a

  • 0

How should I go about handling http uploads that exceeds the post_max_size in a sane manner?

In my configuration post_max_size is a few MB larger than upload_max_filesize
The problems I’m having are:
If a user uploads a file exceeding post_max_size

  • The _POST array is empty
  • The _FILES array is empty, and of course any error codes therein are not present.
  • No other info what kind of form post it is is accessible through theses means.

Part of the problem is that the receiving script takes different actions depending on the contents of the POST.

I do have access to the _SERVER variables and can get clues as to what happened, i.e. CONTENT_TYPE, CONTENT_LENGTH and REQUEST_METHOD. It does however seem very problematic to make guesses based on those contents.

MEMORY_LIMIT (set to 10 times the relevant sizes) and Apaches LimitRequestBody (set to unlimited) are found to not be at fault.

As it stands now I have a hard time even providing any meaningful messages to the user.

Is there any way to retain some form data to get better clues as to what has gone wrong? I’m very reluctant to move away from php.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:46:03+00:00Added an answer on May 22, 2026 at 10:46 pm

    For a simple fix that would require no server side changes, I would use the HTML5 File API to check the size of the file before uploading. If it exceeds the known limit, then cancel the upload. I believe something like this would work:

    function on_submit()
    {
      if (document.getElementById("upload").files[0].size > 666)
      {
        alert("File is too big.");
        return false;
      }
    
      return true;
    }
    
    <form onsubmit="return on_submit()">
    <input id="upload" type="file" />
    </form>
    

    Obviously it’s just a skeleton of an example, and not every browser supports this. But it wouldn’t hurt to use this, as it could be implemented in such a way that it gracefully degrades into nothing for older browsers.

    Of course this doesn’t solve the issue, but it will at least keep a number of your users happy with minimal effort required. (And they won’t even have to wait for the upload to fail.)

    —

    As an aside, checking $_SERVER['CONTENT_LENGTH'] vs the size of the post and file data might help detect if something failed. I think it when there is an error it will be non zero, while the $_POST and $_FILES would both be empty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any open-source libraries that all programmers should know about? I'm thinking something
What are all the common undefined behaviours that a C++ programmer should know about?
I am about to start to developing an iPhone application that should login and
I just starting reading about SEO and realized that I should change my GET
We should forget about small efficiencies, say about 97% of the time: premature optimization
Are there any VC++ settings I should know about to generate better PDB files
As Knuth said, We should forget about small efficiencies, say about 97% of the
Using C# how should I go about extracting titles subtitles and paragraphs from a
Where should I start learning about version control systems? I've used SVN, Team Foundation,
My question is about when a function should be referenced with the extern keyword

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.