How to export images to local folder using php -


how export images local folder using php, data in server system. how export uploaded images in client system ? please give me solution. using php. all.

either keep zipped file images. , request url directly. no role of php, if images folder static. in case image folder not static, , images added/deleted, can create zip using php zip library. best option in order download multiple images @ clients machine.

you can use code below. code below stack overflow post @ how zip whole folder using php

// real path 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 $name => $file) {     // skip directories (they added automatically)     if (!$file->isdir())     {         // real , relative path current file         $filepath = $file->getrealpath();         $relativepath = substr($filepath, strlen($rootpath) + 1);          // add current file archive         $zip->addfile($filepath, $relativepath);     } }  // zip archive created after closing object $zip->close(); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -