Hướng dẫn unzipper php not working - giải nén php không hoạt động
Các nhà thiết kế và nhà phát triển web biết cách mà nó cần thiết để nén các tệp vào một kho lưu trữ zip khi tải lên một số lượng lớn các tệp lên máy chủ. Điều này cũng có nghĩa là bạn cần giải nén tệp sau khi tải xuống. Đối với các nhà phát triển web, họ cố gắng truy cập tất cả các loại thư viện PHP. Kích thước của một số có thể so sánh với kích thước của kho lưu trữ zip. Vì vậy, từ hướng dẫn này, bạn sẽ học cách giải nén các tệp trên máy chủ của mình bằng tập lệnh unzipper.php. Tuy nhiên, trước khi chúng tôi bắt đầu, hãy để đề cập đến các sự kiện cơ bản về Php Unzipper: • Nó thực sự là một công cụ không thể thiếu mỗi khi bạn cần tải lên nhiều tệp và thư mục lên trang web. • Để tiết kiệm thời gian và lưu lượng truy cập của bạn, nó đủ để tải lên một kho lưu trữ zip lên máy chủ và nhanh chóng giải nén nó bằng tập lệnh unzipper.php. • Ngoài chức năng giải nén, nó có thể xem cấu trúc thư mục trên trang web. Đồng thời, cũng có một tùy chọn để xem nội dung của tài liệu lưu trữ zip trên máy chủ mà không cần giải nén nó. • Tập lệnh đi với ủy quyền quản trị viên theo thông tin đăng nhập và mật khẩu. Nó hoàn toàn dễ dàng để cài đặt. Nội phân Chính showShow Giải nén các tệp trên máy chủ với unzipper.php
Gói nó lênbài chuyển hướng unzipper.php script. bài chuyển hướngMã tập lệnh Php Unzippera PHP script that extracts .zip, .rar or .gz archives on webservers. Làm cách nào để giải nén một tập tin với unzipper?Download PHP Unzipper (79 KB). Làm cách nào để giải nén một tệp PHP?Làm cách nào để giải nén một tệp trên máy chủ? Đầu tiên, bạn cần tải xuống tập lệnh unzipper.php vào ổ cứng của bạn. Mở máy chủ lưu trữ của bạn CPanel và điều hướng đến công cụ Trình quản lý tệp. Chọn tùy chọn Tải lên trong bảng điều khiển trên cùng.Bạn cũng có thể tải lên nó bằng FTP Client (ví dụ: Filezilla, Total Commander). Mã tập lệnh Php UnzipperLàm cách nào để giải nén một tập tin với unzipper? prepareExtraction($archive, $destination); } //Create zip archive if(isset($_POST['dozip'])){ $zippath = !empty($_POST['zippath']) ? strip_tags($_POST['zippath']) :'.'; // Resulting zipfile e.g. zipper--2016-07-23--11-55.zip $zipfile = 'zipper-'. date('Y-m-d--H-i') .'.zip'; Zipper::zipDir($zippath, $zipfile); } $timeend = microtime(TRUE); $time = $timeend - $timestart; /** * Class Unzipper */ class Unzipper { public $localdir ='.'; public $zipfiles = array(); public function __construct(){ //read directory and pick .zip and .gz files if($dh = opendir($this->localdir)){ while (($file = readdir($dh)) !== FALSE){ if(pathinfo($file, PATHINFO_EXTENSION)==='zip' || pathinfo($file, PATHINFO_EXTENSION)==='gz' || pathinfo($file, PATHINFO_EXTENSION)==='rar') $this->zipfiles[] = $file; } closedir($dh); if(!empty($this->zipfiles)) $GLOBALS['status'] = array('info'=>'.zip or .gz or .rar files found, ready for extraction'); else $GLOBALS['status'] = array('info'=>'No .zip or .gz or rar files found. So only zipping functionality available.'); } } // Prepare and check zipfile for extraction public function prepareExtraction($archive, $destination){ // Determine paths. if(empty($destination)) $extpath = $this->localdir; else { $extpath = $this->localdir .'/'. $destination; // todo move this to extraction function if(!is_dir($extpath)) mkdir($extpath); } //allow only local existing archives to extract if(in_array($archive, $this->zipfiles)) self::extract($archive, $extpath); } //Checks file extension and calls suitable extractor functions public static function extract($archive, $destination){ $ext = pathinfo($archive, PATHINFO_EXTENSION); switch($ext){ case 'zip': self::extractZipArchive($archive, $destination); break; case 'gz': self::extractGzipFile($archive, $destination); break; case 'rar': self::extractRarArchive($archive, $destination); break; } } //Decompress/extract a zip archive using ZipArchive public static function extractZipArchive($archive, $destination){ // Check if webserver supports unzipping. if(!class_exists('ZipArchive')){ $GLOBALS['status'] = array('error'=>'Error: Your PHP version does not support unzip functionality.'); return; } $zip = new ZipArchive; // Check if archive is readable. if($zip->open($archive)===TRUE){ // Check if destination is writable if(is_writeable($destination .'/')){ $zip->extractTo($destination); $zip->close(); $GLOBALS['status'] = array('success'=>'Files unzipped successfully'); } else $GLOBALS['status'] = array('error'=>'Error: Directory not writeable by webserver.'); } else $GLOBALS['status'] = array('error'=>'Error: Cannot read .zip archive.'); } // Decompress a .gz File public static function extractGzipFile($archive, $destination){ // Check if zlib is enabled if(!function_exists('gzopen')){ $GLOBALS['status'] = array('error'=>'Error: Your PHP has no zlib support enabled.'); return; } $filename = pathinfo($archive, PATHINFO_FILENAME); $gzipped = gzopen($archive, 'rb'); $file = fopen($filename, 'w'); while($string = gzread($gzipped, 4096)) fwrite($file, $string, strlen($string)); gzclose($gzipped); fclose($file); // Check if file was extracted. if(file_exists($destination .'/'. $filename)) $GLOBALS['status'] = array('success'=>'File unzipped successfully.'); else $GLOBALS['status'] = array('error'=>'Error unzipping file.'); } //Decompress/extract a Rar archive using RarArchive public static function extractRarArchive($archive, $destination){ // Check if webserver supports unzipping. if(!class_exists('RarArchive')){ $GLOBALS['status'] = array('error'=>'Error: Your PHP version does not support .rar archive functionality. How to install RarArchive'); return; } // Check if archive is readable. if($rar = RarArchive::open($archive)){ // Check if destination is writable if(is_writeable($destination .'/')){ $entries = $rar->getEntries(); foreach ($entries as $entry){ $entry->extract($destination); } $rar->close(); $GLOBALS['status'] = array('success'=>'Files extracted successfully.'); } else $GLOBALS['status'] = array('error'=>'Error: Directory not writeable by webserver.'); } else $GLOBALS['status'] = array('error'=>'Error: Cannot read .rar archive.'); } } /** * Class Zipper * * Copied and slightly modified from http://at2.php.net/manual/en/class.ziparchive.php#110719 * @author umbalaconmeogia */ class Zipper { /** * Add files and sub-directories in a folder to zip file. * * @param string $folder * Path to folder that should be zipped. * * @param ZipArchive $zipFile * Zipfile where files end up. * * @param int $exclusiveLength * Number of text to be exclusived from the file path. */ private static function folderToZip($folder, &$zipFile, $exclusiveLength){ $handle = opendir($folder); while(FALSE !== $f = readdir($handle)){ // Check for local/parent path or zipping file itself and skip. if($f !='.' && $f != '..' && $f != basename(__FILE__)){ $filePath = $folder .'/'. $f; // Remove prefix from file path before add to zip. $localPath = substr($filePath, $exclusiveLength); if(is_file($filePath)) $zipFile->addFile($filePath, $localPath); else if(is_dir($filePath)){ // Add sub-directory. $zipFile->addEmptyDir($localPath); self::folderToZip($filePath, $zipFile, $exclusiveLength); } } } closedir($handle); } /** * Zip a folder (including itself). * Usage: * Zipper::zipDir('path/to/sourceDir', 'path/to/out.zip'); * * @param string $sourcePath * Relative path of directory to be zipped. * * @param string $outZipPath * Relative path of the resulting output zip file. */ public static function zipDir($sourcePath, $outZipPath){ $pathInfo = pathinfo($sourcePath); $parentPath = $pathInfo['dirname']; $dirName = $pathInfo['basename']; $z = new ZipArchive(); $z->open($outZipPath, ZipArchive::CREATE); $z->addEmptyDir($dirName); if($sourcePath == $dirName) self::folderToZip($sourcePath, $z, 0); else self::folderToZip($sourcePath, $z, strlen($parentPath.'/')); $z->close(); $GLOBALS['status'] = array('success'=>'Successfully created archive '. $outZipPath); } } ?> Unzipper version: Làm cách nào để giải nén một tệp PHP?Làm cách nào để giải nén một tệp trên máy chủ?Làm cách nào để giải nén một tập tin với unzipper?Làm cách nào để giải nén một tệp PHP?right-click to select Extract All, and then follow the instructions. To unzip a single file or folder, double-click the zipped folder to open it. Làm cách nào để giải nén một tệp PHP?Làm cách nào để giải nén một tệp trên máy chủ? Làm cách nào để giải nén một tệp trên máy chủ?Bước 1 - Đăng nhập vào máy chủ của bạn bằng SSH.. Lệnh thiết bị đầu cuối SSH trong Mykinsta..... Cửa sổ thiết bị đầu cuối SSH..... Điều hướng đến thư mục chứa tệp zip của bạn..... Liệt kê các tập tin trong thiết bị đầu cuối..... Các tập tin giải nén trong thiết bị đầu cuối..... Xác minh các tệp đã giải quyết .. |