PDA

View Full Version : การ zip folder ด้วย php



Gen0TypE
02-09-2008, 08:41 AM
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 = &#39;folder&#39;;

// the name of your zip archive to be created
$zipfile = &#39;myziparchive.zip&#39;;



// 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;

ideaza
26-07-2009, 03:47 PM
8iy[

กำลังศึกษาอยู่ อยากได้ การทำ zip ด้วย php ครับ

กำลังศึกษาอยู่ อยากได้ การทำ zip ด้วย php ครับ