global $loginid,$filename; $fname =$filename; //added by sony as on 26 april 2008 // TO ALLOW FREE DOWNLOAd of all files in DOWNLOAD section without login, ADD non-zero value to loginid variable //echo "loginid:".$loginid; //echo $fname; //exit; $loginid="1"; if($loginid!="") { $path="photo/uploadcenter/"; $fullPath=$path.$fname; if ($fd = fopen ($fullPath, "r")) { $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "pdf": header("Content-type: application/pdf"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachement' to force a download break; default; header("Content-type: application/octet-stream"); header("Content-Disposition: filename=\"".$path_parts["basename"]."\""); } header("Content-length: $fsize"); header("Cache-control: private"); //use this to open files directly while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd); exit; //} header('Pragma: private'); header('Cache-control: private, must-revalidate'); $extn = substr(strrchr($fname,'.'),1); //echo $extn; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header ( "Content-Type: $filedatatype" ); header("Content-Disposition: attachment; filename=\"".$path.$fname."\";"); header("Content-Transfer-Encoding: binary"); // header("Content-Length: ".$fsize); //readfile(.$path.$fname); //exit; $fileheader = "Content-type: application/".$extn; header($fileheader); //header("Content-type: pdf/x-ms-iqy"); $fp = fopen($path.$fname,"r"); $filedata=fread($fp,filesize($path.$fname)); fclose($fp); //header("Content-type: text/x-ms-iqy"); header("Content-Disposition: attachment; filename=".$fname); echo $filedata; } else { echo "You have not logged in, Pls register."; ?>
//echo ""; } ?>