phpnewbie09 Posted June 23, 2009 Share Posted June 23, 2009 I have this script: <?php $initFile = "init.xml"; $progressFile = "progress.xml"; $command = "load"; if(isset($_GET["command"]){ $command = $_GET["command"]; } switch($_GET["command"]){ case "save": if (isset($_POST['xml'])) { if(write($_POST['xml'])){ output("", "Synchronisation succeeded."); } else { output("", "Could not write file."); } } else { output("", "Could not find XML for output."); } break; case "load": if(!file_exists($progressFile))} if (!copy($initFile, $progressFile)) { output("", "Could not find XML for output."); } } output("Content-Type: text/xml", read($progressFile); break; } function output($headers="", $output){ if($headers=""){ $headers = "Content-Type: text/plain"; } header ($headers); echo ($output); } function write($xml, $file){ if($f = fopen($file, "w")){ fwrite($f, $xml); fclose($f); return true; } else { return false; } } function read($file){ return file_get_contents($file); } ?> However this script could only update the $progressFile and if I save the file it will only do them locally, I want to save the XML file into the server. Anyone can help me? Or does anyone have any script to save file to the server from a remote machine? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/163316-help-with-php-script-to-save-xml-file/ Share on other sites More sharing options...
JonnoTheDev Posted June 23, 2009 Share Posted June 23, 2009 FTP the file after writing. Look at the ftp functions in the php manual. Quote Link to comment https://forums.phpfreaks.com/topic/163316-help-with-php-script-to-save-xml-file/#findComment-861842 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.