Back
VFS
VFS
VFS
Forward


Step 7: File Uploads and Virtual File Storage

Generating HTML code for embedded MP3 player:

Horde::downloadUrl() takes care of browser quirks.


<?php

/**
* Returns the HTML code that displays an object to play a certain MP3.
*
* @param int $id  The MP3 ID.
*
* @return string  The player HTML code.
*/
function playerHTML($id)
{
    if (!
Mopple::fileExists($id)) {
        return
'';
    }
    
$url = Horde::applicationUrl('download.php');
    
$url = Horde::downloadUrl($id . '.mp3', array('id' => $id), $url);
    return
'<object data="' . $url . '" type="audio/mpeg" width="300" height="70"><embed src="' . $url . '" /></object>';
}

?>