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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:50:23+00:00 2026-05-27T17:50:23+00:00

I’m trying to POST a file in a multipart message. The problem is that

  • 0

I’m trying to POST a file in a multipart message. The problem is that I need to pass two extra parameters with that file. And I want them to be accessible in POST parameters array. The question is whether is possible to add part to multipart message so that it’ll be interpreted as POST parameter? Or am I wasting time?

I want that e.g:

--1BEF0A57BE110FD467A\r\n
Content-Disposition: form-data; name="name1"\r\n
\r\n
value\r\n

be accsessible with $_POST['name1']

PS: as far as I know, if one uploads file with actionscript FileReference.upload(urlRequest) and specifies post params in urlRequest then they’ll be in $_POST

  • 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-27T17:50:24+00:00Added an answer on May 27, 2026 at 5:50 pm

    What you want to do is in fact exactly the way that multipart messages work in relation to the $_POST array.

    Consider the following HTML form:

    <form action="/somefile.php" method="post" enctype="multipart/form-data">
      <input name="text1" type="text" />
      <input name="text2" type="text" />
      <input name="text3" type="text" />
      <input name="file" type="file" />
      <input type="submit" />
    </form>
    

    Now lets say we populate the three text inputs with value1, value2 and value3, we select a file called file.txt, and press submit. This will result in a request that looks something like this:

    POST /somefile.php HTTP/1.1
    Host: somehost.com
    Accept: */*
    User-Agent: MyBrowser/1.0
    Content-Type: multipart/form-data; boundary="this-is-a-boundary-string"
    
    --this-is-a-boundary-string
    Content-Dispostion: form-data; name="text1"
    
    value1
    --this-is-a-boundary-string
    Content-Dispostion: form-data; name="text2"
    
    value2
    --this-is-a-boundary-string
    Content-Dispostion: form-data; name="text3"
    
    value3
    --this-is-a-boundary-string
    Content-Dispostion: form-data; name="file"; filename="file.txt"
    Content-Type: text/plain
    
    This is the contents of file.txt
    --this-is-a-boundary-string--
    

    When we look at it in PHP, if we print_r($_POST); we should get something like this:

    Array
    (
       [text1] => value1
       [text2] => value2
       [text3] => value3
    )
    

    …and if we print_r($_FILES);:

    Array
    (
       [file] => Array
       (
          [name] => file.txt
          [type] => text/plain
          [size] => 32
          [tmp_name] => /tmp/dskhfwe43232.tmp
          [error] => 0
       )
    )
    

    …so you can see, the parts of the message where the Content-Disposition: header does not contain a filename="" element are added to the $_POST array, and those with one are treated as file uploads and added to $_FILES.

    When building a multipart/form-data message to send to a server, I find it easiest to build the HTML form that you are mimicking with the request, and construct your HTTP message based on how that HTML form would behave.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I need a function that will clean a strings' special characters. I do NOT
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.