I'm looking for a PHP script that can accept an XML file via a POST, then send a response....
Does anyone have any code that could do this?
So far the only code I have is this but not sure about the response or if indeed I am even going in the right direction as XML characters are not saved correctly. Any ideas?
<?php
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ){
$postText = file_get_contents('php://input');
}
$datetime=date('ymdHis');
$xmlfile = "myfile" . $datetime . ".xml";
$FileHandle = fopen($xmlfile, 'w') or die("can't open file");
fwrite($FileHandle, $postText);
fclose($FileHandle);
?>
My files are all empty...the contents is not being written to them. They are being created.
//source html
<form action="quicktest.php" method="post" mimetype="text/xml" enctype="text/xml" name="form1">
<input type="file" name="xmlfile">
<br>
<input type="submit" name="Submit" value="Submit">
</form>
//destination php
$file = $_POST['FILES']['xmlfile'];
$fileContents= file_get_contents($file['tmp_name']);
$datetime=date('ymdHis');
$xmlfile="myfile" . $datetime . ".xml";
$FileHandle=fopen($xmlfile, 'w') or die("can't open file");
fwrite($FileHandle, $postText);
fclose($FileHandle);
I'm not talking about uploading a file. Someone wants to send an XML file on a regular basis through a HTTP connection.
I just need a script running on my server to accept their post to my URL and then save the file to my server and send them a response back saying acknowledged or accepted.