Jump to content

Write output to file.


Blamm

Recommended Posts

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]

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.