Click on a button to implement the packaging of multiple images to download, you need to be prompted, that is, to indicate the package files to what directory of the kind, for guidance
Click on a button to implement the packaging of multiple images to download, you need to be prompted, that is, to indicate the package files to what directory of the kind, for guidance
------Solution--------------------
Package here: http://justcoding.iteye.com/blog/660812
Download the hint of that.
$file = ' Test.zip ';
if (file_exists ($file)) {
Header (' Content-type:application/octet-stream ');
Header (' content-disposition:attachment; Filename= '. basename ($file));
Header (' Content-length: '. FileSize ($file));
ReadFile ($file);
}
?>
------Solution--------------------
Cases
$zipname = ' Test.zip ';
$filelist = Array_slice (Glob (' images/* '), 0, 10);//List of files to be compressed
$zip = new Ziparchive;
------Solution--------------------
Ziparchive::overwrite);
foreach ($filelist as $FN) {
$zip->addfile ($FN);
}
$zip->close ();
------Solution--------------------
Reference:
package here: http://justcoding.iteye.com/blog/660812
Download the hint of that.
$file = ' Test.zip ';
if (file_exists ($file)) {
Header (' Content-type:application/octet-stream ');
Header (' content-disposition:attachment; Filename= '. basename ($file));
Header (' Content-length: '. FileSize ($file));
ReadFile ($file);
}
?>
References:
Example
$zipname = ' Test.zip ';
$filelist = Array_slice (Glob (' images/* '), 0, 10);//List of files to be compressed
$zip = new Ziparchive;
------Solution--------------------
Ziparchive::overwrite);
foreach ($filelist as $FN) {
$zip->addfile ($FN);
}
$zip->close ();
The integration of these two can be, after testing the completed.
Then I wrote a method for the combination of the master and the second floor:
function Zipanddownload ($zipFileName, $zipDir) {
if (file_exists ($zipFileName)) {
Unlink ($zipFileName);
$zipFile = new Ziparchive ();
$fileList = Array_slice (Glob ($zipDir), 0); List of files to compress
------Solution--------------------
Ziparchive::overwrite);
foreach ($fileList as $files) {
$zipFile-AddFile ($files);
}
$zipFile-Close ();
if (file_exists ($zipFileName)) {
Header (' Content-type:application/octet-stream ');
Header (' content-disposition:attachment; Filename= '. basename ($zipFileName));
Header (' Content-length: '. FileSize ($zipFileName));
ReadFile ($zipFileName);
}
}
}