Intro -- Introduction in usage of
HTTP_DownloadIntroduction
With this package you can easily handle (hidden) downloads.
Hidden means not accessible by the public - for
instance if you want to restrict access to particular downloads.
It supports HTTP compression, caching and partial downloads,
resuming and sending raw data, for example from database BLOBs.
ATTENTION:
You shouldn't use this package together with ob_gzhandler or
zlib.output_compression enabled in your php.ini, especially
if you want to send already gzipped data!
Usage Examples:
Have a look at the following examples:
Example 32-1. Static send: 1 $params = array(
2 'file' => '../hidden/download.tgz',
3 'contenttype' => 'application/x-gzip',
4 'contentdisposition' => array(HTTP_DOWNLOAD_ATTACHMENT, 'latest.tgz'),
5 );
6
7 $error = HTTP_Download::staticSend($params, false); |
|
Example 32-2. Send a hidden file: 1 $dl = &new HTTP_Download();
2 $dl->setFile('../hidden/download.tgz');
3 $dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, 'latest.tgz');
4 // with ext/magic.mime
5 // $dl->guessContentType();
6 // else:
7 $dl->setContentType('application/x-gzip');
8 $dl->send(); |
|
Example 32-3. Send arbitrary data: 1 $dl = &new HTTP_Download();
2 $dl->setData($blob_from_db);
3 $dl->setLastModified($unix_timestamp);
4 $dl->setContentType('application/x-gzip');
5 $dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, 'latest.tgz');
6 $dl->send(); |
|