/** * Use content (from file, from database, other source...) and pass it to the browser as a file * * @param string $content * @param string $type MIME type * @param string $name File name * @param integer $size File size * @param boolean $force_download Send Content-Disposition: attachment to force * save dialog * @param boolean $die * @return boolean */ function download_contents($content, $type, $name, $force_download = false, $die = true) { if (!defined('HTTP_LIB_PATH')) { require ANGIE_PATH . '/classes/http/init.php'; } // if // Prepare variables if (empty($name)) { $name = basename($path); } // if $disposition = $force_download ? HTTP_DOWNLOAD_ATTACHMENT : HTTP_DOWNLOAD_INLINE; // Prepare and send file $download = new HTTP_Download(); $download->setData($content); $download->setContentType($type); $download->setContentDisposition($disposition, $name); $download->send(); if ($die) { die; } // if }