Uploading XML to network storage (http) - "Necessary data rewind wasn't possible"

Hi !

I’m trying to upload a XML to a storage located on the network of the company.

I’ve written a script with two functions :

  • the first one is used to serialize data to XML. This one’s working fine.
  • with the second one i’m trying to upload this serialized string to the storage. I’m using a Coroutine with WWWForm to upload it but it doesn’t work. I’m getting a “necessary data rewind wasn’t possible” error whenever i’m launching the upload.

Here’s the code :

    // Upload of serialized XML
    IEnumerator SaveOuput()
    {
        string url = "http://10.0.0.180/rc_BCS/XML";

        WWWForm form = new WWWForm();
        form.AddField("output", serializedOuput);
        WWW upload = new WWW(url, form);
        yield return upload;

        if (upload.error == null)
        {
            Debug.Log("XML succesfully uploaded");
        }
        else
        {
            Debug.Log("Error uploading XML : " + upload.error);
        }
    }

The variable serializedOutput is the string where the XML has been serialized.

Any clues ? Do I need a PHP script in the folder where I wan’t to upload the XML to make things work ?

Thanks !

Problem solved !

I just needed this simple PHP script :

<?php

if ( isset( $_POST['output'] ) )
{
    file_put_contents( 'output.xml', $_POST['output'] );
}
?>