×ªÔØ
£¨ÂíÂí¡¡2001Äê08ÔÂ30ÈÕ 13:18£©
ÄãÒ»¶¨»áЦÎÒ"ÏÂÔØÎļþ"Èç´Ë¼òµ¥¶¼ÖµµÃ˵£¿µ±È»²¢²»ÊÇÏëÏóÄÇô¼òµ¥¡£ÀýÈçÄãÏ£Íû¿Í»§ÒªÌîÍêÒ»·Ý±í¸ñ£¬²Å¿ÉÒÔÏÂÔØÄ³Ò»Îļþ£¬ÄãµÚÒ»¸öÏë·¨Ò»¶¨ÊÇÓà "Redirect"µÄ·½·¨£¬Ïȼì²é±í¸ñÊÇ·ñÒѾÌîдÍê±ÏºÍÍêÕû£¬È»ºó¾Í½«ÍøÖ·Ö¸µ½¸ÃÎļþ£¬ÕâÑù¿Í»§²ÅÄÜÏÂÔØ£¬µ«Èç¹ûÄãÏë×öÒ»¸ö¹ØÓÚ"ÍøÉϹºÎï"µÄµç×ÓÉÌÎñÍøÕ¾£¬¿¼Âǰ²È«ÎÊÌ⣬Äã²»ÏëÓû§Ö±½Ó¸´ÖÆÍøÖ·ÏÂÔØ¸ÃÎļþ£¬±ÊÕß½¨ÒéÄãʹÓÃPHPÖ±½Ó¶ÁÈ¡¸Ãʵ¼ÊÎļþÈ»ºóÏÂÔØµÄ·½·¨È¥×ö¡£³ÌÐòÈçÏ£º
$file_name = "info_check.exe";
$file_dir = "/public/www/download/";
if (!file_exists($file_dir . $file_name)) { //¼ì²éÎļþÊÇ·ñ´æÔÚ
echo "ÎļþÕÒ²»µ½";
exit;
} else {
$file = fopen($file_dir . $file_name,"r"); // ´ò¿ªÎļþ
// ÊäÈëÎļþ±êÇ©
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
// Êä³öÎļþÄÚÈÝ
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
exit;}
¶øÈç¹ûÎļþ·¾¶ÊÇ"http" »òÕß "ftp" ÍøÖ·µÄ»°£¬ÔòÔ´´úÂë»áÓÐÉÙÐí¸Ä±ä£¬³ÌÐòÈçÏ£º
$file_name = "info_check.exe";
$file_dir = "http://www.easycn.net/";
$file = @ fopen($file_dir . $file_name,"r");
if (!$file) {
echo "ÎļþÕÒ²»µ½";
} else {
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=" . $file_name);
while (!feof ($file)) {
echo fread($file,50000);
}
fclose ($file);
}
ÕâÑù¾Í¿ÉÒÔÓÃPHPÖ±½ÓÊä³öÎļþÁË¡£
£¨ÔðÈα༠ʤϲ chensx@staff.ccidnet.com£©
PHPʵÏÖÎļþ°²È«ÏÂÔØ-PHP½Ì³Ì,Îļþ´¦Àí
À´Ô´£ºÎ´Öª
×÷ÕߣºÎ´Öª
ʱ¼ä£º2003-07-25
µã»÷£º
×îÐÂÆÀÂÛ¹²ÓÐ 0 Î»ÍøÓÑ·¢±íÁËÆÀÂÛ
²é¿´ËùÓÐÆÀÂÛ
·¢±íÆÀÂÛ
- ÔÞÖúÉÌÁ¬½Ó
ÈÈµã¹Ø×¢