Click on a button to implement the packaging of multiple images to download, you need to have to reveal that, is to suggest the package files to what directory of the kind, for guidance

Source: Internet
Author: User
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);
}
}
}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.