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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:21:51+00:00 2026-06-01T18:21:51+00:00

Say there is a form: <form enctype=multipart/form-data method=post> <input name=’foo’> <input name=’foo’> <input type=submit>

  • 0

Say there is a form:

<form enctype="multipart/form-data" method="post">
    <input name='foo'>
    <input name='foo'>
    <input type=submit>
</form>

posting to my php script. How (if at all) can I find out the two values submitted in these boxes. $_POST['foo'] gives the second value, but I want both.

I realize this can be done by using <input name='foo[]'> (which would make $_POST['foo'] an array). Due to certain coding decisions adding the square brackets is undesirable (read: would require some restructuring), and it seems that there should be an easy way to do this.

If the enctype was ‘application/x-www-form-urlencoded’ then parsing it would be easy, but “multipart/form-data” is more complex and could have a 30MB file in it!

Not to mention PHP has already parsed the post data.

Please can someone tell me that PHP kept that information that it parsed from $_POST and that I can access it without re-parsing.

Thanks!

  • 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-06-01T18:21:52+00:00Added an answer on June 1, 2026 at 6:21 pm

    You can’t access it, and $_POST won’t keep it. If the browser even sent it (which it should have), the array key would be overwritten when it is parsed into the $_POST superglobal from the HTTP request.

    It’s sort of equivalent to defining an array like:

    array(
      'one' => 1,
      'two' => 2,
      'one' => 3
    );
    
    Array(2) {
      ["one"]=>
          int(3)
      ["two"]=>
          int(2)
    }
    

    The array key one is set initially, but when another value is encountered during the initialization, it is immediately overwritten.

    Not great for your situation (multipart form) but applicable to future readers:

    If you read in the entire raw HTTP POST, you may be able to parse out the value you need.

    <?php $postdata = file_get_contents("php://input"); ?> 
    

    This would give you a string like

     foo=value1&foo=value2
    

    You can’t pass it to parse_str() though, as you’ll run into the same array key overwrite problem. You would have to do string parsing to pull out the other value.

    It really is easier to change them to an array with [] if possible.

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

Sidebar

Related Questions

Let's say we have this code: <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input
Let say I have a post from like this: <form action=myApp/form_action.asp method=post> First name:
Say there is a method Operation , public ObjectOut Operation(ObjectIn input) What is the
Lets say there is a form with a submit button. I found out that
How can I check if user gave input to input-form and say if there
For our webservice, I wrote some logic to prevent multipart/form-data POSTs larger than, say,
So I've been trying to figure out the method of posting form data from
Say there is a folder, '/home/user/temp/a40bd22344'. The name is completely random and changes in
Is there anyway to send post data to a php script other than having
If a website user submits an HTML form with: (1) a post method; (2)

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.