Avatar of Joel_Sisko
Joel_SiskoFlag for United States of America asked on

Post XML file to PHP...


I am having a hard time understanding how to use a php script that will allow a third party application automatically "post" a small xml file to my server running the php script.

So the flow is: Client application--->xml file--->myphpscript--->directory on my server.

Please no pointers to resources on the internet that are not complete solutions to the problem. I have been searching them all day already.


PHPApache Web ServerPerl

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I have seen some other posts that were using the file directives to this? Is what you are recommending a better way?

I am referring to something like this that I have seen:


$folder = "/path/to/file/";
$count = count(glob($folder . "*")) + 1;
$ext = explode(".",$_FILES['filefield']['name']);
$filename = $folder . "rawfile" . $count . "." . $ext[1];

}//end if


It totally depends on how the xml is delivered to your script.

Your second example assumes that the xml is uploaded as a file upload (as part of a multipart post). The php://input approach assumes that the post data itself, is the actual xml string.

Assume that the file being transfered was a text file or any file for that fact, would the above code allow that file to be posted and copied/moved to the directory stated in the code? My problem is I understand posting (barely) as it relates to a form that you manually click the submit button.

Thanks for the help so far.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

Your file with move_uploaded_file should be fine when the xml is uploaded using a form-like request.

So are you saying it can not be posted to? How do I change it so it can be posted to?