Q: จะ zip folder ไปทำไม?
A: อ้าว เวลาจะโหลด source code มา backup จะได้โหลดทีเดียวไง ไม่ต้องโหลดเป็นร้อยไฟล์
Q: ก็ใช้ exec ของ php ไปสิ
A: เกิดอยู่บน host ฟรี แล้วเค้า disable function นี้ไว้ล่ะ
เออ นั่นสิ งั้นมาดูกันดีกว่าว่าทำไง แหะๆ
มีข้อแม้ว่า server ต้องติดตั้ง ZipArchive extensions ก่อนนะ
[hide=15][code]
<?php
// GRD ZIP ARCHIVER
// by Piotr GRD
// http://grd.go.pl/
// grd@gazeta.pl
// created 2008-05-05
// free to use and modify as long as you keep info above
// requirements: php zip extensions with ZipArchive class
// SETTINGS
// directory you want to compress with everything inside
// . - for root
// folder - for some folder
// folder/subfolder - for some subfolder
// do not add ending slash
$directory = 'folder';
// the name of your zip archive to be created
$zipfile = 'myziparchive.zip';
// DO NOT TOUCH BELOW IF YOU DONT KNOW WHAT IT IS
// all the process below
$filenames = array();
// function that browse the directory and all subdirectories inside
function browse($dir) {
global $filenames;