Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $image = file_get_contents('http://url.com/image.jpg');
- file_put_contents('tmp/15.jpg', $image);
- $image = file_get_contents('http://url.com/image.jpg');
- file_put_contents('tmp/16.jpg', $image);
- $image = file_get_contents('http://url.com/image.jpg');
- file_put_contents('tmp/17.jpg', $image);
- $files = array(
- 'tmp/15.jpg',
- 'tmp/16.jpg',
- 'tmp/17.jpg'
- );
- $valid_files = array();
- if(is_array($files)) {
- foreach($files as $file) {
- if(file_exists($file)) {
- $valid_files[] = $file;
- }
- }
- }
- if(count($valid_files > 0)){
- $zip = new ZipArchive();
- $zip_name = "images.zip";
- if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){
- $error .= "* Sorry ZIP creation failed at this time";
- }
- foreach($valid_files as $file){
- $zip->addFile($file);
- }
- $zip->close();
- if(file_exists($zip_name)){
- header("Pragma: public");
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Cache-Control: private",false);
- header('Content-type: application/zip');
- header('Content-Disposition: attachment; filename="'.$zip_name.'"');
- readfile($zip_name);
- unlink($zip_name);
- }
- } else {
- echo "No valid files to zip";
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement