PHP로 온라인 위젯 생성 도구를 만들고 있는데, 필요한 모든 것을 내보낼 수 있습니다. 단지 문제는 사용자가 압축을 풀어야한다는 것입니다. iBooks에서 작동하도록 폴더에 .wdgt 확장자를 추가하십시오. 프로세스의 일부를 더 쉽게 만들 수있는 방법이 있습니까? 예 : 압축을 풀면 .wdgt 폴더가 있거나 더 나은 wdgt로 다운로드하십시오. 이 잘 작동ZipArchive()에 .wdgt 폴더를 보관하십시오.
//zip name
$archiveName = 'widget.zip';
$fileNames = array();
//scan through directories, and add to array
foreach(scandir($workingDir) as $content){
$fileNames[] = $workingDir.$content;
}
foreach(scandir($resources) as $content){
$fileNames[] = $resources.$content;
}
archiveFiles($fileNames, $archiveName);
function archiveFiles($fileNames, $archiveName){
//init new ZipArchive()
$zip = new ZipArchive();
//open archive
$zip->open($archiveName);
if($zip->open($archiveName, ZIPARCHIVE::OVERWRITE) !==TRUE){
exit("Cannot open <$archiveName>\n");
}
else{
//archive create, now add files
foreach($fileNames as $files){
if('.' === $files || '..' === $files) continue;
//get just the filename and extension
$fileName = explode("/", $files);
$num = (count($fileName) - 1);
$theFilename = $fileName[$num];
//add file into the archive - full path of file, new filename
$zip->addFile($files,$theFilename);
}
$zip->close();
header('Location: http://MYURL/'.$archiveName) ; //Redirects to the zip archive
exit;
}
}
: 여기
내가 ZIP 파일을 작성해야하는 코드입니다. 필요한 콘텐츠가있는 .wdgt 폴더를 다운로드하거나 필요한 콘텐츠가있는 .wdgt 폴더를 압축 할 수 있어야합니다.내가 변화 시도 $archiveName
$archiveName = "widget.wdgt.zip";
하고 $archiveName = "widget.wdgt.zip";
Windows에서 잘 압축을 풀 수 있었다 $archiveName = "widget.wdgt";
. MAC에서 단지 오류가 발생했습니다. iBook의 저작자와 마찬가지로 MAC에서 작동해야합니다. 위젯은 다음에서 작동합니다.
zip 파일을 어떻게 만듭니 까? – georg
@ thg435 - 저는 ZipArchive()에 대한 모든 자습서가 zip을 생성하는 기본 방법을 사용합니다. 나는 우편 번호를 만들 수 있으며, 다운로드하고 압축을 풀 수 있습니다. 문제가되는 아카이브 내에 .wdgt 확장명을 가진 폴더를 만드는 것입니다. – MikeJ
괜찮지 만 코드를 게시하십시오. – georg