|
|
|
|
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);
}
}
?> | | |
|
| 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 | | | PHP4 DirectoryIterator Class Categories : PHP, PHP Classes, Filesystem, Directories | | | Keep() - maintenance function for backup folders Categories : PHP, Filesystem, Maintenance | | | Contents Page - a script to build contents pages. Categories : Complete Programs, PHP, Utilities, Filesystem | | | Display list of files within current and subdirectories (recursively) showing
each file as an anchored link and each directory as a category header. Categories : Filesystem, Directories, Arrays, PHP | | | Single-file PHP news system with automatic folder structure creation Categories : PHP, Filesystem, Arrays | | | How to create an empty file? (touch) Categories : Filesystem, PHP | | | Listing the 10 most recently updated files in a given dir by using last-
modified variable and printing to html with link to the file Categories : PHP, Directories, Filesystem | | | Unix Disk Information with graphs Categories : PHP, Shell Scripting, Filesystem | | | PHP Image Compression using GD library Categories : PHP, Compression, GD image library, Graphics | | | Save and restore files into postgresql database (PHP SCRIPT) PHP CLASS Categories : PHP, Databases, PostgreSQL, Filesystem | | | Differences between two files Categories : PHP, Filesystem, Tip | | | how can I read the entire contents of a file into a string? Categories : Filesystem, Strings, PHP | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | |
|
|
|