View Single Post
Old 23-10-2005, 14:35   #10
punky
Inactive
 
Join Date: Jun 2003
Age: 45
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: megaupload.com Question on Effect

Actually, that example doesn't look totally clear.

Here is a clearer example, from the PHP docs, so its more trustworthy.

PHP Code:
           $filename = 'dummy.zip';
           
$filename = realpath($filename);

           
$file_extension = strtolower(substr(strrchr($filename,"."),1));

           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 
"jpe": case "jpeg":
               case 
"jpg": $ctype="image/jpg"; break;
               default: 
$ctype="application/force-download";
           }

           if (!
file_exists($filename)) {
               die(
"NO FILE HERE");
           }

           
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: $ctype");
           
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
           
header("Content-Transfer-Encoding: binary");
           
header("Content-Length: ".@filesize($filename));
           
set_time_limit(0);
           @
readfile("$filename") or die("File not found.") 
save that in a php file. Alter the $filename bit for your file, and then do window.location="http://www.site.com/yournewphpfile.php"
punky is offline   Reply With Quote