ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


PHP - ÆÄÀÏ´Ù¿î·Îµå ÇÔ¼ö
12³â Àü
<?php

dl_file("file.zip"); // or whatever the file name is.
function dl_file($file){
//First, see if the file exists
if (!is_file($file)) { die("<b>404 File not found!</b>"); }

//Gather relevent info about file
$len = filesize($file);
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
//This will set the Content-Type to the appropriate setting for the file
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;
   case "mp3": $ctype="audio/mpeg"; break;
   case "wav": $ctype="audio/x-wav"; break;
   case "mpeg":
   case "mpg":
   case "mpe": $ctype="video/mpeg"; break;
   case "mov": $ctype="video/quicktime"; break;
   case "avi": $ctype="video/x-msvideo"; break;

//The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files)
   case "php":
   case "htm":
   case "html":
   case "txt": die("<b>Cannot be used for ". $file_extension ." files!</b>"); break;

default: $ctype="application/force-download";
}
//Begin writing headers
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");

//Use the switch-generated Content-Type
header("Content-Type: $ctype");

//Force the download
$header="Content-Disposition: attachment; filename=".$filename.";";
header($header );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
readfile($file);
exit;
}
?>

ÃßõÃßõ : 478 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
73
PHP ¸ÞÀÏ(mail) ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ Ã·ºÎÈ­ÀÏ Àü¼ÛÇϱâ
72
PHP ÇÔ¼ö °£´Ü Á¤¸®
71
PHP¿¡¼­ ¼¼¼Ç(session) »ç¿ëÇϱâ
70
PHP explode ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿­ ºÐ¸®
69
PHP split ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿­ ºÐ¸®
68
PHP À̸§ÀÌ °°Àº Æûű×(Form Tag)ÀÇ °ª(value) ó¸®Çϱâ
67
PHP ¿À´Ã³¯Â¥¸¦ ±âÁØÀ¸·Î ÀÌÀü,ÀÌÈÄ ³¯Â¥±¸Çϱâ
66
PHP ÇÑ±Û ¹®ÀÚ¿­ ÀÚ¸£±â
65
PHP ¹öÀü È®ÀÎÇϱâ
64
PHP - SELECT·Î ¹ÝȯµÈ ·¹ÄÚµå °¹¼ö¿Í Ä÷³ÀÇ °¹¼ö¸¦ ¾Ë·ÁÁÖ´Â ÇÔ¼ö
63
PHP Æû(form)°ªÀÇ À¯È¿¼º üũ
62
PHP no-cache ¼³Á¤(µÚ·Î°¡±â ¸·±â)
61
PHP ¿¡·¯ ó¸® ÇÔ¼ö die
60
PHP MySQL ¸í·É¾î ½ÇÇà ÇÔ¼ö mysql_query
59
PHP·Î MySQL µ¥ÀÌÅͺ£À̽º ¸¸µé±â(»ý¼ºÇϱâ)
58
PHP¿Í ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÑ µå·Ó´Ù¿î ¸Þ´º
57
PHP - xml ÀоîµéÀ̱â(read) Ŭ·¡½º
56
PHP ÆÄÀÏ ½Ã½ºÅÛ(File System) ´Ù·ç±â #1
55
PHP ÆÄÀÏ ³»¿ë Àбâ(freadÇÔ¼ö)
54
PHP ÆÄÀÏ ÇÑÁÙ Àбâ(fgetsÇÔ¼ö)
53
PHP ÇöÀç ÆäÀÌÁöÀÇ µµ¸ÞÀθíÀ̳ª urlµîÀÇ Á¤º¸ ¾Ë¾Æ¿À±â
52
PHP - À¥»çÀÌÆ®ÀÇ À¯È¿¼º üũ
51
fsockopen ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ À¥»çÀÌÆ®¿¡ µ¥ÀÌÅÍ Àü¼ÛÇϱâ
PHP - ÆÄÀÏ´Ù¿î·Îµå ÇÔ¼ö
49
PHP ÆÄÀÏ 1¹ÙÀÌÆ®¾¿ Àбâ(fgetcÇÔ¼ö)
48
PHP °£´ÜÇÑ ÆÄÀÏ ¾÷·Îµå(upload) ¿¹Á¦
47
PHP ¹®ÀÚ¿­ÀÇ ±æÀ̸¦ °°°Ô ¸¸µé±â
46
PHP $HTTP_COOKIE_VARS·Î °ªÀÌ ¾È ³Ñ¾î¿Ã¶§
45
PHP ³­¼ö¸¦ ÀÌ¿ëÇÑ ÄíÆù¹øÈ£ »ý¼ºÇϱâ
44
PHP - POST ¹æ½ÄÀÇ ÆÄÀÏ ¾÷·Îµå ´Ù·ç±â
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.