아래 스크립트는 실제로 제 홈피에서 사용하는 소스입니다.
약간의 문제가 있어 이렇게 질문을 올립니다.
// DOWNLOAD.php
//다운받을 음반($folder)을 선택하면 해당 폴더의 내용을 보여주며
//파일에 하이퍼링크를 걸어주는 스크립트입니다.
$handle=opendir("/디렉토리/$folder");
while( $file = readdir($handle) )
if( $file!="." && $file!=".." && eregi(".mp3$",$file) ) {
$file_=urlencode($file);
echo "<a href="SEND.php?no=$no&folder=$folder&file=$file_">$file</a><br>";
}
closedir($handle);
<?
//SEND.php
//파일명을 넘겨받아 클라이언트로 파일을 전송하는 스크립트입니다.
$file=urldecode($file);
$down_file="/home/classics/pub/$folder/$file";
if( !is_readable($down_file) ) Alert("Cannot open $file");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file");
if( !readfile($down_file) ) Alert("Cannot read $file");
?>
문제는 파일명에 ' " 같은 특수문자가 있으면
url변수로 파일명이 제대로 넘어가지 않는다는 것입니다.
그러면 "Cannot open $file" 경고메시지가 뜨죠.
urlencode 함수를 쓰면 해결된다던데...
제가 잘못 쓴건지...
잘 모르겠습니다.
조언을 부탁드립니다.--The Day of Tear - LACRIMOSA
To the Memory of Banished Angel