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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:54:24+00:00 2026-05-24T00:54:24+00:00

I have done some research regarding on how to use file_get_content with post. And

  • 0

I have done some research regarding on how to use file_get_content with post. And I have also read this one which is I honestly don’t understand since I am not that familiar with PHP. Below is my php code in getting my json and used it for my ajax request, using methog GET.:

<?php 
    echo(file_get_contents("http://localhost:8001/" . $_GET["path"] . "?json=" . urlencode($_GET["json"])));
?>

Now, I am using method POST and I dont know how to modify my php code to post my data from my javascript. Below is my data which I wanted to post in my url request (that is also what I used as json in method GET):

{"SessionID":"9SQLF17XcFu0MTdj5n",
  "operation":"add",
  "transaction_date":"2011-7-28T00:00:00",
  "supplier_id":"10000000108",
  "wood_specie_id":"1",
  "lines":  [{"...":"...","..":"..."},{"...":"...","..":"..."}],
  "scaled_by":"SCALED BY",
  "tallied_by":"TALLIED BY",
  "checked_by":"CHECKED BY",
  "total_bdft":"23.33",
  "final":"N"}

I just need to change this code

echo(file_get_contents("http://localhost:8001/" . $_GET["path"] . "?json=" . urlencode($_GET["json"])));

with POST to send my post my data.

EDIT:
I need to produce a request like this:

http://localhost/jQueryStudy/RamagalHTML/processjson.php?path=getData/supplier?​json={"SessionID":"KozebJ4SFqdqsJtRpG6t1o3uQxgoeLjT"%2C"dataType":"data"}
  • 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-24T00:54:25+00:00Added an answer on May 24, 2026 at 12:54 am

    You can pass a Stream Context as the third argument to file_get_contents. With the Stream Context, you can influence how the HTTP request will be made, e.g. you can change the Method, add Content or arbirtrary headers.

    file_get_contents($url, false, stream_context_create(
        array (
            'http' => array(
                'method'=>'POST',
                'header' => "Connection: close\r\nContent-Length: $data_len\r\n",
                'content'=>$data_url
            )
        )
    ));
    

    After each request, PHP will automatically populate the $http_response_header which will contain all the information about the request, e.g. Status Code and stuff.

    $data_url = http_build_query (array('json' => $_GET["json"]));
    $data_len = strlen ($data_url); 
    
    echo file_get_contents("http://localhost:8001/" . $_GET["path"], false, stream_context_create(
        array (
            'http' => array(
                'method'=>'POST',
                'header' => "Connection: close\r\nContent-Length: $data_len\r\n",
                'content'=>$data_url
            )
        )
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done some research, and majority of the examples I have found use
Ok I am still learning this... I have Googled and done some research but
Have done some research into this topic, but found no relevant answers. What I
I have done some research on this subject, and found out, that Gzipping and
I have done some research and found that I can use: string retUrl =
I have done some research on this question before deciding to ask it. I
I have done some research and still confused, This is my outcome of that
I have done some research on this question and most answers are a few
Have done some research and found some stuff that may be helpful. I would
I have done some research on the above and found that I am able

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.