note 62458 deleted from function.header by betz
| From: | betz@php.net | Date: | Wed, 01 Mar 2006 10:44:06 +0000 |
| Subject: | note 62458 deleted from function.header by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-104614@lists.php.net to get a copy of this message | ||
Note Submitter: vivekanandan
----
I trying to write a code to download more than one file at a time, My code is below.. This is not
working Please help me ....
<?
$sizem = count($user);
$sizem = $sizem-1;
for($i=0;$i<=$sizem;$i++){
if($logourl[$i] != "-NF-"){
downloadimg($logourl[$i]);
}
}
function downloadimg($d)
{
if($d!="")
{
$path=$d;
$fullpath = $d;
$Onlyfile = explode("/",$fullpath);
//print_r($Onlyfile);
$ArrCnt = count($Onlyfile);
$ArrCnt = $ArrCnt-1;
$SourceFile = $Onlyfile[$ArrCnt];
$filename=$SourceFile;
}
$file_extension = strtolower(substr(strrchr($filename,"."),1));
$fileloc="$path";
switch( $file_extension )
{
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
// send headers to browser to initiate file download
header("Content-Disposition: attachment;
filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($fileloc));
readfile("$fileloc");
exit();
}
?>