Ne-Lexa / php-zip

PhpZip is a php-library for extended work with ZIP-archives.
MIT License
491 stars 60 forks source link

Add files from remote #87

Open fakhamatia opened 2 years ago

fakhamatia commented 2 years ago

Description
PHP has a function called copy copy get two parameters, source and destination. We can use a remote file for source not a local file, like: copy('http://someserver.com/somefile.zip','./somefile.zip') Please add feature to add remote files for function addFile

Example

$zipFile = new \PhpZip\ZipFile();
try {
    $zipFile
        ->addFile('http://192.168.98.242/store/0/2022/03/06/16/2022-03-06_16-33-06_131715438_7843520/2022-03-06_16-33-06_131715438_0_1_0_L1_P.jpg', './test.jpg')
        ->saveAsFile("/var/www/html/temp/temp.zip")
        ->close();
} catch (\PhpZip\Exception\ZipException $e) {
   echo "Error: " . $e->getMessage();
} finally {
    $zipFile->close();
}