에 PHP를 통해 우편을 만들어이 링크 나 특정 디렉토리에 압축을 만들고 싶습니다 compress/archive folder using php script특정 디렉토리
<?php
// Config Vars
$sourcefolder = "./" ; // Default: "./"
$zipfilename = "myarchive.zip"; // Default: "myarchive.zip"
$timeout = 5000 ; // Default: 5000
// instantate an iterator (before creating the zip archive, just
// in case the zip file is created inside the source folder)
// and traverse the directory to get the file list.
$dirlist = new RecursiveDirectoryIterator($sourcefolder);
$filelist = new RecursiveIteratorIterator($dirlist);
// set script timeout value
ini_set('max_execution_time', $timeout);
// instantate object
$zip = new ZipArchive();
// create and open the archive
if ($zip->open("$zipfilename", ZipArchive::CREATE) !== TRUE) {
die ("Could not open archive");
}
// add each file in the file list to the archive
foreach ($filelist as $key=>$value) {
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
// close the archive
$zip->close();
echo "Archive ". $zipfilename . " created successfully.";
// And provide download link ?>
<a href="http:<?php echo $zipfilename;?>" target="_blank">
Download <?php echo $zipfilename?></a>
를 통해 PHP를 사용하여 ZIP 파일을 만들려면이 멋진 코드를 발견했다.
파일 이름 대신 zip 파일 이름의 전체 경로를 사용해 보셨습니까? –
"이 훌륭한 코드를 발견했습니다"- 실제로 어떻게 작동하는지 이해하려고 했습니까? 아니면 앱에 붙여 넣기 전에 조정할 수 있습니까? – Gordon
하지만 멋지네. – AlienWebguy