Here is an example for you :
-
- $host = "your ftp host";
- $user = "your ftp username";
- $pass = "your ftp password";
- if (class_exists("ZipArchive"))
- {
- $ftp = ftp_connect($host);
- ftp_login($ftp,$user,$pass);
- $zip = new ZipArchive;
- if ($zip->open("test.zip") === true)
- {
- ftp_get($ftp,"eshan.php","index.php",FTP_ASCII);
- $zip->addFile("eshan.php","eshan.php");
- $zip->close();
- unlink("eshan.php");
- echo "ok";
- }
- else {echo "ERROR";}
- }
- else {echo "Very sad";}
- ?>
First we have connected with ftp server and by using ftp_get() function we have downloaded file.
By using addFile() method of ZipArchive class we have added downloaded file.
After that we have deleted downloaded file using unlink() function.
No comments:
Post a Comment