Note that there are some explanatory texts on larger screens.

plurals
  1. POreceive xml file via post in php
    primarykey
    data
    text
    <p>I'm looking for a PHP script that can accept an XML file via a POST, then send a response....</p> <p>Does anyone have any code that could do this?</p> <p>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?</p> <pre><code>&lt;?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); ?&gt; </code></pre> <p>My files are all empty...the contents is not being written to them. They are being created.</p> <pre><code>//source html &lt;form action="quicktest.php" method="post" mimetype="text/xml" enctype="text/xml" name="form1"&gt; &lt;input type="file" name="xmlfile"&gt; &lt;br&gt; &lt;input type="submit" name="Submit" value="Submit"&gt; &lt;/form&gt; //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); </code></pre> <hr> <p>I'm not talking about uploading a file. Someone wants to send an XML file on a regular basis through a HTTP connection.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload