이 코드를 다운로드 단추로 다운로드하려면 다운로드하십시오.다운로드 이미지 링크를 사용하여 PHP
<?
$filename = $_GET["filename"];
$buffer = file_get_contents($filename);
/* Force download dialog... */
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
/* Don't allow caching... */
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
/* Set data type, size and filename */
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($buffer));
header("Content-Disposition: attachment; filename=$filename");
/* Send our file... */
echo $buffer;
?>
것은이 파일의 이름은 예를 들어, 파일 이름에 전체 경로로 끝나는,이 코드입니다 :
<a href="download.php?filename=images/something.jpg">
라는 이미지 "images_something.jpg와 함께 종료 "
"images_ "을 최종 파일 이름에서 제거하고 싶습니다. 지금까지 행운이 없었습니다.
도움 주셔서 감사합니다. 당신은 폴더 이름이없는 파일 이름 부분을해야하는 경우
그 스크립트를 사용하면 누구나 서버의 파일을 다운로드 할 수 있으므로 사용하기 전에 보안을 조사 할 것입니다. – JJJ
나는 그 사실을 알지 못했다. 나를 보안 할 방법을 연구 할 수있는 웹 사이트를 가르쳐 주시겠습니까? –