PHPã§ãã¡ã¤ã«ãã¦ã³ãã¼ããããæ¹æ³
ã¾ãã¯åºæ¬ã
header('Content-Disposition: attachment; filename="hoge.txt"'); header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.strlen($buf)); print $buf;
ãã¡ã¤ã«ã«ãªã£ã¦ããã¤ããã¦ã³ãã¼ãã
header('Content-Disposition: attachment; filename="'.basename($filepath).'"'); header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.filesize($filepath)); readfile($filepath);
PEAR::File_Archiveã使ããç°å¢ãªããã£ã¡ããå§ãã
headerããã¬ããèªåã§æ¸ããªãã¦ãããã
toArchive()ã®ç¬¬ï¼å¼æ°ã®æ¡å¼µåãå¤ããã°å§ç¸®ãå¯è½ã
(tar, gz, tgz, bz2, tbz, zip, gzip, ar, debã対å¿)
ãããã¡ã®å 容ãa.txtã¨ãã¦ãã¦ã³ãã¼ãã
require_once 'File/Archive.php'; $fa = new File_Archive(); $fa->extract($fa->readMemory($buf, 'a.txt'), $fa->toOutput());
ãã¡ã¤ã«ãzipã§ãã¦ã³ãã¼ãã
require_once 'File/Archive.php'; File_Archive::setOption("zipCompressionLevel", 9); $fa = new File_Archive(); $fa->extract($filepath, $fa->toArchive("hoge.zip", $fa->toOutput()));
è¤æ°ã®ãã¡ã¤ã«ãzipã§ã¾ã¨ãã¦å§ç¸®ãã¦ãã¦ã³ãã¼ãã
require_once 'File/Archive.php'; $fa = new File_Archive(); $src = $fa->readMulti(); $src->addSource(File_Archive::read("huge1.txt", "hoge/huge1.txt")); $src->addSource(File_Archive::read("huge2.txt", "hoge/huge2.txt")); $src->addSource(File_Archive::read("huge3.txt", "hoge/huge3.txt")); $fa->extract($src, $fa->toArchive("hoge.zip", $fa->toOutput()));
extract()ã®ç¬¬ï¼å¼æ°ãèªã¿è¾¼ã¿æ¹æ³ã§ã第2å¼æ°ãåºåæ¹æ³ã
ä¸ã®ä¾ãå°ããã¤ããã£ã¦ããã°ãããããªçµã¿åããã§ãã¦ã³ãã¼ãã§ããã
ãã¦ã³ãã¼ãç¨ã®toOutput()ã®ä»ã«ãtoFile(),toMail(),toVariable()ã¨ã
ããã®ã§é常ã«å¿ç¨ç¯å²ãåºãã