Link to home
Start Free TrialLog in
Avatar of Joel_Sisko
Joel_SiskoFlag for United States of America

asked on

Post XML file to PHP...

Experts,

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.

Thanks,

Joel
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Joel_Sisko

ASKER

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:


<?
if(is_uploaded_file($_FILES['filefield']['tmp_name'])){

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


}//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.

Joel
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?

Joel