|
Step 7: File Uploads and Virtual File Storage
This script sends the MP3 file to the browser.
<?php
@define('MOPPLE_BASE', dirname(__FILE__)); require_once MOPPLE_BASE . '/lib/base.php'; require_once MOPPLE_BASE . '/lib/Driver.php';
$id = Util::getFormData('id');
$driver = &Mopple_Driver::singleton($conf['storage']['driver']); /* Make sure that we have a valid ID and that this MP3 actually * belongs to the user. */ $mp3 = $driver->get($id); if (is_a($mp3, 'PEAR_Error')) { Horde::fatal($mp3, __FILE__, __LINE__); }
/* Get file contents from VFS. */ $data = Mopple::getFile($id); if (is_a($data, 'PEAR_Error')) { Horde::fatal($data, __FILE__, __LINE__); }
/* Send HTTP headers to the browser. */ $browser->downloadHeaders($id . '.mp3', 'audio/mpeg', true, strlen($data));
/* Send content to the browser. */ echo $data;
/* Make sure that no additional data is sent. */ exit;
?>
|