FTP_ZIP_X.php
ftp hosting gratisan lambat banget, sedangkan jika upload zip, ketika diekstrak gagal terus kalo pake file manager bawaan.
mau tidak mau, aku harus turun tangan.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* WARNING: DATA LOSS; (YOU HAVE BEEN WARNED) | |
* | |
* @version 20160124071141 | |
* @version 20201023144831 | |
* @author anovsiradj | |
* @author Touqeer Shafi | |
* @link https://superuser.com/a/1030589 | |
* | |
* create zip inside target directory (ex: /somedir/ => /somedir/somedir.zip) | |
* upload zip (ex: /public_html/somedir.zip) | |
* run this script from http(s). | |
* the result should be /public_html/somedir/ | |
* delete zip (ex: /public_html/somedir.zip) | |
* | |
*/ | |
$regex = '/\.zip$/'; | |
$file = scandir(__DIR__); | |
$file = array_filter($file, fn($i) => preg_match($regex, $i) == 1); | |
$file = current($file); | |
if (empty($file)) die('No ZIP'); | |
$path_zip = __DIR__ . "/${file}"; | |
$path_dir = preg_replace($regex, '', $file); | |
$path_dir = __DIR__ . "/${path_dir}"; | |
$zip = new ZipArchive; | |
if ($zip->open($path_zip)) { | |
$zip->extractTo($path_dir); | |
$zip->close(); | |
} |
Komentar
Posting Komentar
Komentar ...