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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:10:32+00:00 2026-05-15T22:10:32+00:00

I receive POST request on my api.php script. The content red using this code:

  • 0

I receive POST request on my api.php script. The content red using this code:

$fp = fopen('php://stdin', 'r');
$all = "";
while($line = fgets($fp, 4096)) { 
    $all .= $line; 
}
echo $all;

looks like this:

------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="intro"

O
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="title"

T
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="apiKey"

98d32fdsa
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="method"

/media/add
------------V2ymHFg03ehbqgZCaKO6jy
Content-Disposition: form-data; name="upload_field"; filename="original_filename.png"
Content-Type: image/png


------------V2ymHFg03ehbqgZCaKO6jy--

As you can see I get 4 parameters called intro, title, apiKey and method, and one file called original_filename.png with size of 1460 bytes.

Unfortunately, my $_POST array is empty. What is weird when orginal_filename.png is less than 1450 bytes $_POST contains all parameters, and stdin is empty.

I would like to be able to read these fields like normal human PHP being from $_POST.

What to do in order to read this POST request parameters properly from $_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-15T22:10:32+00:00Added an answer on May 15, 2026 at 10:10 pm

    As I just read in the manual, raw post data is not available with enctype=”multipart/form-data” but can you can also try with

    $fp = fopen('php://stdin', 'rb');
    

    Please pay attention to the “b” flag.

    Also, make sure that always_populate_post_data=On in your php.ini

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

Sidebar

Related Questions

When my PHP script receives data from an AJAX POST request, the $_POST variables
I'm using the post-receive-email script included with git. (Source is here .) It works
This seems simple but I can't figure it out. I receive post data in
I'm currently using gitolite, and in my post-receive hook I'm pushing to a (local)
I am trying to POST an image to imageshack using their API and Play
I am trying to post the content in a file as a param using
This is a follow up post to some problems I've had using Java built
I'm building an API in PHP. One of the methods is place.new (PUT request).
I am trying to create a PHP script which can request data, such as
I am using Twilio API to receive SMS text messages. I want to store

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.