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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:54:04+00:00 2026-06-03T07:54:04+00:00

Searched a lot for this on StackOverflow and Google but can’t seem to find

  • 0

Searched a lot for this on StackOverflow and Google but can’t seem to find an answer to this specific situation

I’m working with a client that sends me an XML file via PHP POST and this is the code I use:

$xml = file_get_contents('php://input');
$xmlStripped = stripslashes($xml);
$xmlContent = simplexml_load_string($xmlStripped);
print_r($xmlContent);

For testing I also uploaded the XML file directly to my server and did it like this:

$xml = file_get_contents('http://www.site.com/linktoxml.xml');
$xmlStripped = stripslashes($xml);
$xmlContent = simplexml_load_string($xmlStripped);
print_r($xmlContent);

And then it works fine, it prints out the XML as an object.

The form I use to upload is like this:

<form action="http://app.site.com/upload" method="POST">
<input type="file" name="file" id="file ">
<input type="submit" value="upload">
</form>
  • 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-03T07:54:05+00:00Added an answer on June 3, 2026 at 7:54 am

    file_get_contents('php://input'); would normally give you the raw RFC 1867 data, not the file itself. The file data is enveloped inside this request data. In your case, it gives an empty string because PHP discards such data after processing it in order to save memory.

    PHP, however, automatically processes and decodes the RFC 1867 data. What you have to do is (besides validating that $_FILES['file']['tmp_name'] exists and is a string):

    $xml = file_get_contents($_FILES['file']['tmp_name']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched a lot for this but I can't find any answer about how
I searched a lot but I can't find an answer. In my contact.php I
I've searched a lot within SO but I can't find the right answer for
HI! I have searched a lot, but I didn't find the answer to this
I searched lot about this topics but can't find a proper solution. I am
Ok, I searched the internet and stackoverflow but I just can't seem to find
Searched a lot about this problem but never found a answer, that solved it.
I have searched a lot and tried much but I can not find the
I searched a lot and can't find the solution for this RegExp (I have
I have searched lot for this answer but there is no near answer for

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.