php로 download를 구현하려고 합니다.
client는 따로 아직 구현을 안했고...
download.php를 호출하면 해당 폴더에 들은 파일들이 다운이 되어야 합니다.
1. 여러 파일을 한페이지 않에서 한번에 보낼 수 없나요??
2. 파일 한개만 전송했을 때도 제대로 저장이 안됩니다.
3. 여러파일 보낼때는
[Tue May 14 11:21:12 2013] [error] [client 127.0.0.1] PHP 1. {main}() /var/www/load/download.php:0
[Tue May 14 11:21:12 2013] [error] [client 127.0.0.1] PHP 2. header(*uninitialized*) /var/www/load/download.php:20
[Tue May 14 11:21:12 2013] [error] [client 127.0.0.1] PHP Warning: Cannot modify header information - headers already sent in /var/www/load/download.php on line 21
이런 워닝이 뜹니다..
4. 저장할때 폴더 선택하고 저장되는게 아니라 파일을 선택해야지 저장창이 닫히 더라구요..
코드 첨부해 볼께요...
<?php
ob_start();
$version = 6;
$dir = './'.$version.'/';
$files = scandir($dir);
foreach( $files as $file)
{
if( is_file($dir.$file) )
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$file);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($dir.$file));
ob_clean();
flush();
readfile($dir.$file);
}
}
exit();
?>