我正在寻找一个可以通过POST接受
XML文件的
PHP脚本,然后发送响应….
有人有任何代码可以做到这一点吗?
到目前为止,我唯一的代码是这个但不能确定的回应,或者如果我确实是正确的方向,因为XML字符不能正确保存.有任何想法吗?
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);
?>
我的文件都是空的…内容没有被写入他们.正在创建它们
//source html
//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);
我不是在说上传文件.有人想通过HTTP连接定期发送XML文件.
我只需要一个在我的服务器上运行的脚本来接受他们的发布到我的URL,然后将该文件保存到我的服务器,并向他们发送一个回应,确认或接受.