Blamm Posted April 13, 2010 Share Posted April 13, 2010 Hi. SOrry of this is a really dumb question but I am a complete newbie to PHP. I have managed to lash something up to extract XML from my media server and turn it into XSLT and would really like to have the resulting file saved to a directory on my server without intervention but cant work out how to do it. Here is my code: Any help greatfully received [pre]<?php header('Content-type: application/xspf+xml'); // Sets the MIME type to XSPF header('Content-Disposition: attachment; filename="playlist.xspf"'); //Sets the file name for the playlist. $id = $_GET['id']; // Gets the ID passed by the URL $url = "http://localhost:3689/rsp/db/".$id."?type=browse"; // Uses the ID to set the URL for querying the right playlist. $dom = new domDocument(); $dom->load("rsp2xspf.xsl"); // Loads the XSL file. $proc = new xsltprocessor; $xsl = $proc->importStylesheet($dom); $document = new DomDocument(); $document->load("$url"); // Loads the XML from the RSP query print $proc->transformToXml($document); ?>[/pre] Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted April 13, 2010 Share Posted April 13, 2010 Been a while since I have played with any DOM stuff, but wouldn't it just be $proc->save('filename.xml'); ? Quote Link to comment Share on other sites More sharing options...
simonrs Posted April 13, 2010 Share Posted April 13, 2010 Think you're best served by the file_put_contents function. For more info take a look here: http://uk3.php.net/manual/en/function.file-put-contents.php If your server is running on a unix server, your script will need to have write permissions for the directory. The command you would need for this is chmod, you will need ftp or command line access to the server to use it. Google it for more information! A big part of web development is research. Good luck! Quote Link to comment 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.