PHP를 사용하여 다운로드 할 gzipped XML 파일을 어떻게 제공 할 수 있습니까?
문제
DB에서 XML 파일을 만드는 PHP 스크립트가 있습니다. 스크립트가 XML 데이터를 만들고 즉시 .gzip 파일을 다운로드 할 수 있도록하고 싶습니다. 나에게 몇 가지 아이디어를 주시겠습니까?
감사!
해결책
GZIP 압축을 쉽게 적용 할 수 있습니다 Gzencode 기능.
<?
header("Content-Disposition: attachment; filename=yourFile.xml.gz");
header("Content-type: application/x-gzip");
echo gzencode($xmlToCompress);
다른 팁
이 같은?
<?php
header('Content-type: application/x-gzip');
header('Content-Disposition: attachment; filename="downloaded.gz"');
$data = implode("", file('somefile.xml'));
print( gzencode($data, 9) ); //9 is the level of compression
?>
당신이 없다면 GZIP 모듈 사용 가능,
<?php
system('gzip filename.xml');
?>
제휴하지 않습니다 StackOverflow