Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

create zip file command line

for ubuntu : zip -r example.zip original_folder
Comment

make zip file command

zip -r example.zip original_folder   // For Mobaxterm || Ubuntu etc
Comment

create zip file

// Get real path for our folder
$rootPath = realpath('folder-to-zip');

// Initialize archive object
$zip = new ZipArchive();
$zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);

// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($rootPath),
    RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file)
{
    // Skip directories (they would be added automatically)
    if (!$file->isDir())
    {
        // Get real and relative path for current file
        $filePath = $file->getRealPath();
        $relativePath = substr($filePath, strlen($rootPath) + 1);

        // Add current file to archive
        $zip->addFile($filePath, $relativePath);
    }
}

// Zip archive will be created only after closing object
$zip->close();
Comment

PREVIOUS NEXT
Code Example
Shell :: How to install cookies react 
Shell :: git make directory 
Shell :: how to push cloned repo 
Shell :: kill process bash 
Shell :: Git - create new branch and switch to that new branch 
Shell :: bash print a blank line 
Shell :: merge master to a branch 
Shell :: bash "=~" example 
Shell :: how to install windows sdk 
Shell :: nuget reinstall packages 
Shell :: store environment variables in firebase functions 
Shell :: install docker desktop ubuntu 
Shell :: rm vs rmdir 
Shell :: git rebase branch 
Shell :: opera browser for fedora 
Shell :: svelte getting started typescript 
Shell :: make vscode git mergetool 
Shell :: import docker image 
Shell :: how to check raspbian os version 
Shell :: docker push image 
Shell :: check memcached status 
Shell :: replace a newline using sed linux bash 
Shell :: how to kill recycling process linux 
Shell :: update all packages in cmd 
Shell :: install ruby environment on ubuntu 20.04 
Shell :: chocolatey update yarn to particular version 
Shell :: svn info git equivalent 
Shell :: ubuntu open file system from terminal 
Shell :: snap install fingerprint 
Shell :: webp to png ubuntu command 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =