Like this code?
Show the author your appreciation.
I was looking for a way to create ZIP files containing images on a linux box and ran into several problems. Now I found a way to manage that, thank to the PHP mailing list :o) Below my example.
Of course, this thing is just made to suite my needs, so you need to alter it to make it work for you.
Cheers!
Chris
<?php
$nr = $_GET [ 'nr' ];
if( eregi ( "../" , $nr )) {
die( "No playing with directories here..." );
}
$directory = '_kfz_images/' . $nr . '/full/' ;
$dir = opendir ( $directory );
$i = 1 ;
while( $file = readdir ( $dir )) {
$dest = "temp/ImageFilename" . $nr . "_" . $i . ".jpg" ;
if( eregi ( "jpg" , $file )) {
copy ( $directory . $file , $dest );
$i ++;
}
}
$now = time ();
header ( "Content-Type: application/force-download" );
header ( 'Content-Disposition: attachment;
filename="ZIPfileName' . $now . '_Download.zip"' );
exec ( "zip " . $now . "_archive.zip temp/* 2>&1" , $output );
readfile ( $now . "_archive.zip" );
$tempdir = opendir ( "temp" );
while( $tempfile = readdir ( $tempdir )) {
if( eregi ( "jpg" , $tempfile )) {
unlink ( "temp/" . $tempfile );
}
}
?>
Fetching product details from the commission junction website using php Categories : PHP , FTP , Filesystem , Compression 3 lines of Code to extract Tar, Zip, Gzip etc.. Categories : PHP , Filesystem , PHP Classes , Compression Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP , FTP , Filesystem , PHP Classes , Compression Selecting a random line from a text file Categories : PHP , Filesystem , Arrays , Beginner Guides Convert a File database into MySQL Categories : PHP , Filesystem , Databases , MySQL , Beginner Guides Remote File Size Categories : PHP , Filesystem , HTTP , Sockets Remote File Saving with PHP - Download and serve a remote file. The content of the file will be updated at fixed intervals. Categories : PHP , Filesystem , Cache , Sockets , HTTP Quote For the Day Categories : PHP , Utilities , Filesystem How to ifconfig down/up a list of IP's Categories : Arrays , Strings , Filesystem , PHP Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays , Filesystem , Variables , Strings , PHP Finds files on your site, uses UNIX find command. Categories : Complete Programs , Filesystem , PHP Introduction to Language Files Categories : PHP , Filesystem , Beginner Guides Email attachment code Categories : PHP , Email , Filesystem Get the correct extension and MIME types of an image, even when the filename is incorrect. Categories : PHP , Filesystem , General SQL Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML - Categories : PHP , Directories , FTP , Filesystem , HTML and PHP