farban Posted May 16, 2009 Share Posted May 16, 2009 I have two php files that simply need modifing so that they communicate with this xml file <?xml version="1.0" encoding="UTF-8" ?> <songs> <song filename="The Birthday Massacre - Nothing And Nowhere - 06 - Video Kid.mp3" track="Video Kid" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 07 - Over.mp3" track="Over" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 08 - Broken.mp3" track="Broken" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 09 - The Dream.mp3" track="The Dream" artist="The Birthday Massacre" album="Nothing And Nowhere" /> <song filename="The Birthday Massacre - Nothing And Nowhere - 01 - Happy Birthday.mp3" track="Happy Birthday" artist="The Birthday Massacre" album="Nothing And Nowhere" /> </songs> here is the two php files upload.php <h1>Jukebox Playlist</h1> <p>Enter the Artist and Title names as you want them to appear on the jukebox. It'll take a few minutes to upload a song after you click submit, so leave it and don't close the page until you see it added to the Current Entries list.</p> <form action="playlistaction.php" method="post" enctype="multipart/form-data"> <table> <tr> <td colspan="2"class="labelcell"><label for="artist">Artist:</label></td> <td colspan="2"class="fieldcell"><input type="text" id="artist" name="artist" tabindex="1"/></td> </tr> <tr> <td colspan="2"class="labelcell"><label for="title">Title:</label></td> <td colspan="2"class="fieldcell"> <input type="text" id="title" name="title" tabindex="2"/><br /> </td> </tr> <!-- <tr> <td colspan="2"class="labelcell"><label for="path">URL:</label></td> <td colspan="2"class="fieldcell"> <input type="text" id="url" name="url" tabindex="3"/> <br /> </td> </tr>--> <tr> <td colspan="2"class="labelcell"><label for="userfile">Song Upload</label></td> <td colspan="2"><input name="userfile" type="file" id="userfile" tabindex="4"></td></tr> </td> </tr> <td colspan="4"><input type="submit" name="upload" class="box" value="Submit" tabindex="5" /></td> </table> </fieldset> </form> <h2>Current entries:</h2> <p>Artist - Title - URL</p> <?php $xml = simplexml_load_file("..songs/playlist.xml"); foreach($xml->songs[0]->attributes() as $a => $b) { echo $a,'="',$b,"\"</br>"; } ?> ?> playlistaction.php <?php $uploadDir = 'Bulrush\songs'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } } $song = array( 'track' => $_POST['track'], 'artist' => $_POST['artist'], 'album' => $_POST['album'], 'song filename' => $filePath, ); $doc = new DOMDocument(); $doc->load( 'playlist.xml' ); $doc->formatOutput = true; $r = $doc->getElementsByTagName("songs")->item(0); $title = $doc->createElement("track"); $title->appendChild( $doc->createTextNode( $song["track"] ) ); $b->appendChild( $title ); $artist = $doc->createElement("artist"); $artist->appendChild( $doc->createTextNode( $song["artist"] ) ); $b->appendChild( $artist ); $artist = $doc->createElement("album"); $artist->appendChild( $doc->createTextNode( $song["album"] ) ); $b->appendChild( $artist ); $url = $doc->createElement("song filename"); $url->appendChild( $doc->createTextNode( $song["song filename"] ) ); $b->appendChild( $url ); $r->appendChild( $b ); $doc->save("player.xml"); header("Location: {$_SERVER['HTTP_REFERER']}"); ?> i have tried to change it and modify it so it works with the xml but i just dont know what to change. its important that its changed to the xml file 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.