I've got a PHP file that when run in the browser saves a number of XML files successfully as follows:
$fileName = 'savedFiles/'.$invoiceNumber.'xml';
// Save XML
$xml->asXML();
//Format XML to save indented tree rather than one line
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
$dom->save($fileName);
I'd like to schedule this PHP file to be performed via the Windows Task Scheduler, so have setup a simple .bat file as follows:
@ECHO OFF
php.exe -f "C:\Program Files\FileMaker\FileMaker Server\HTTPServer\conf\sites\processDownloads.php"
When this is executed via the Task Scheduled no .xml files are generated - I'm getting this error in the Application Log:
PHP Warning: DOMDocument::save(xml_files/Invoice123.xml): failed to open stream: No such file or directory in C:\Program Files\FileMaker\FileMaker Server\HTTPServer\conf\sites\processDownloads.php on line 442
Line 442 is the line that saves the XML:
$dom->save($fileName);
I've set the task schedule to run as Admin and "Run with highest privileges" is selected. I can't see any permissions issues, especially given it works in the browser and the schedule is set to run as Administrator.