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 815397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:40:37+00:00 2026-05-15T01:40:37+00:00

I’m using PHP for file uploads. In the PHP manual it shows an example

  • 0

I’m using PHP for file uploads. In the PHP manual it shows an example using a MAX_FILE_SIZE hidden field, saying that it will detect on the client side (i.e. the browser) whether the file is too large or not.

I’ve just tried the example in Firefox, Chrome and IE and it doesn’t work. The file is always uploaded, even if it is way larger than the specified hidden field.

Incidentally, if the file is larger than MAX_FILE_SIZE then calling move_uploaded_file doesn’t work, so it seems the variable is having an effect server-side, but not client-side.

  • 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-15T01:40:37+00:00Added an answer on May 15, 2026 at 1:40 am

    On MAX_FILE_SIZE

    Read This:

    …At http://pk.php.net/manual/en/features.file-upload.post-method.php and equivalent locations in other formats, it is stated
    that browsers take the value of a MAX_FILE_SIZE form field into
    account.

    This information is repeated elsewhere on the web and in books, but
    appears to originate from the PHP documentation (it does not appear in
    terms of other server-side technologies
    ).

    There is nothing in any of the HTML, HTTP or related specs to indicate
    that this is the case (in particular RFC 1867 which introduced file
    uploads to HTML doesn’t mention it
    , so it isn’t even a case of a kludge
    that was mentioned in the first RFC and then dropped) nor does it make
    sense in the context of the HTML specs (there is nothing to indicate any
    relationship between that particular hidden input and the file input).
    The only statements about hidden fields I could find in any of them was
    warnings in the security considerations sections against user-agents
    basing any file-related operations on anything mentioned in a hidden
    field.

    No browsers appear to perform this as an “extension”. Indeed given that
    there are potentially other possible meanings for a hidden field with
    that name in an application handling several file uploads, it would have
    to be considered a design flaw any any did.

    I submit that there is no such mechanism in mainstream browsers (if any
    at all) and indeed shouldn’t be. Reference to it should be dropped from
    documentation.

    I’d further suggest that since this idea has propagated from this
    documentation elsewhere that a note about it not working should to be
    added.

    If a mechanism is required or desired for more rapidly handling this
    sort of file handling issue then it requires functionality to allow PHP
    to intercept streams being uploaded before request completion, which
    would be completely different to how this documentation suggest it
    should be dealt with, even if it was true…

    • http://www.juangiordana.com.ar/blog/2007/12/08/max_file_size-erroneo/

    the code below come from swfUpload php implementation:

    // Check post_max_size (http://us3.php.net/manual/en/features.file-upload.php#73762)
        $POST_MAX_SIZE = ini_get('post_max_size');
        $unit = strtoupper(substr($POST_MAX_SIZE, -1));
        $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
    
        if ((int)$_SERVER['CONTENT_LENGTH'] > $multiplier*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) {
            header("HTTP/1.1 500 Internal Server Error");
            echo "POST exceeded maximum allowed size.";
            exit(0);
        }
    // Validate the file size (Warning the largest files supported by this code is 2GB)
        $max_file_size_in_bytes = 2147483647;           
        $file_size = @filesize($_FILES[$upload_name]["tmp_name"]);
            if (!$file_size || $file_size > $max_file_size_in_bytes) {
                HandleError("File exceeds the maximum allowed size");
                exit(0);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 406k
  • Answers 406k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To my knowledge they are identical. I think there maybe… May 15, 2026 at 6:12 am
  • Editorial Team
    Editorial Team added an answer Copy the jar into your project lib folder. Then right… May 15, 2026 at 6:12 am
  • Editorial Team
    Editorial Team added an answer The caption uses a default TTStyle to render itself (see… May 15, 2026 at 6:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.