Blamm
-
Posts
1 -
Joined
-
Last visited
Never
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Write output to file.
in PHP Coding Help
Posted
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]