링크걸면 다운이 안되거나 이상한 이름으로 변경되어 다운되는 경우가 있는데
이걸 해보려고 이리저리 돌아다니고 시간도 많이 잡아 먹었네요.
혹시 저처럼 헤메시는 분 있을까봐 소스 올려드려요.
제가 해본것은 jpg화일과 ai화일 다운되도록 한것 입니다. jpg화일도 그냥 열리는 경우가 대부분인데
jpg다운되구요. ai의 경우 ps확장자로 다운이 되었는데 이걸사용하니 정상적으로 다운되더군요.
-------------------------------------------------------------------------------------------------------
<?
$code = "/home/자신계정아이디/public_html/home/doc/down"; <--- 이부분만 자신의 환경에 맞게
$file="$code/$filename"; // 화일이 실제로 있는 위치를..
$file_size=filesize($file);
// 브라우저 골라서 헤더를 따로 따로 전송 해 준다.(5.5 일때는 다르게 해줘야 함)
if( strstr($HTTP_USER_AGENT,"MSIE 5.5")){
header("Content-Type: doesn/matter ");
header("Content-Disposition: filename=$filename ");
header("Content-Transfer-Encoding: binary ");
header("Pragma: no-cache");
header("Expires: 0");
}else{
Header("Content-type: file/unknown");
Header("Content-Disposition: attachment; filename=$filename");
Header("Content-Description: PHP3 Generated Data");
header("Pragma: no-cache");
header("Expires: 0");
}
if(is_file("$file")){
$fp = fopen("$file","r");
if (!fpassthru($fp))
fclose($fp);
}
?>
사용은
down.php 로 저장하면
down.php?filename=파일명<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
이걸 해보려고 이리저리 돌아다니고 시간도 많이 잡아 먹었네요.
혹시 저처럼 헤메시는 분 있을까봐 소스 올려드려요.
제가 해본것은 jpg화일과 ai화일 다운되도록 한것 입니다. jpg화일도 그냥 열리는 경우가 대부분인데
jpg다운되구요. ai의 경우 ps확장자로 다운이 되었는데 이걸사용하니 정상적으로 다운되더군요.
-------------------------------------------------------------------------------------------------------
<?
$code = "/home/자신계정아이디/public_html/home/doc/down"; <--- 이부분만 자신의 환경에 맞게
$file="$code/$filename"; // 화일이 실제로 있는 위치를..
$file_size=filesize($file);
// 브라우저 골라서 헤더를 따로 따로 전송 해 준다.(5.5 일때는 다르게 해줘야 함)
if( strstr($HTTP_USER_AGENT,"MSIE 5.5")){
header("Content-Type: doesn/matter ");
header("Content-Disposition: filename=$filename ");
header("Content-Transfer-Encoding: binary ");
header("Pragma: no-cache");
header("Expires: 0");
}else{
Header("Content-type: file/unknown");
Header("Content-Disposition: attachment; filename=$filename");
Header("Content-Description: PHP3 Generated Data");
header("Pragma: no-cache");
header("Expires: 0");
}
if(is_file("$file")){
$fp = fopen("$file","r");
if (!fpassthru($fp))
fclose($fp);
}
?>
사용은
down.php 로 저장하면
down.php?filename=파일명<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
댓글 1개
게시글 목록
| 번호 | 제목 |
|---|---|
| 12181 | |
| 12180 | |
| 12179 | |
| 348 | |
| 12178 | |
| 12177 |
PHP
php환경 변수 출력 입니다.
|
| 12176 |
PHP
PHP팁 (보안 등) 입니다.
|
| 12175 |
PHP
문자열 자르는 함수 입니다.
|
| 12174 | |
| 12173 | |
| 12161 |
정규표현식
파싱 예제입니다.
11
|
| 12160 | |
| 12159 | |
| 12158 | |
| 12157 | |
| 12156 | |
| 12155 | |
| 12154 |
JavaScript
지난 시간 경과시간 페이스북 sns 처럼 보여주기 javascript 버전
|
| 12151 | |
| 12150 |
PHP
php환경맞춤 부분 입니다.
|
| 12149 | |
| 12148 | |
| 12147 | |
| 12146 | |
| 12144 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기