Hello forums!!
I havent use the php downloader script(ie using headers).
Can anybody suggest me how to write downloading script in php?
Thanks in advance to all of you
simple dowloader script in php ??
Moderator: General Moderators
I found this one,
I dont know how effective is this?
any comments on this code:
I dont know how effective is this?
any comments on this code:
Code: Select all
<?php
function getmimetype ($filename) {
static $mimes = array(
'\.jpg$|\.jpeg$' => 'image/jpeg',
'\.gif$' => 'image/gif',
'\.png$' => 'image/png',
'\.html$|\.html$' => 'text/html',
'\.txt$|\.asc$' => 'text/plain',
'\.xml$|\.xsl$' => 'application/xml',
'\.pdf$' => 'application/pdf'
);
foreach ($mimes as $regex => $mime) {
if (eregi($regex, $filename)) return $mime;
}
return 'text/plain';
}
$file = $_GET["file"];
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: ' . getmimetype($file));
header('Content-Disposition: attachment; filename=' . basename($file) . ';');
header('Content-Length: ' . filesize($file));
readfile($file);
?>