前言:批量下載網上有一堆,可是無奈都基本是對本身項目做用不大,研究了一下,分享和記錄php
1.首先要知道這個是從html頁面發起的因此必需要加入這段話才行html
//以前嘗試用ajax和layer彈層來實現發現都會產生錯誤所以必需要用這個方法才行,前端的方法
location.href = 你想要訪問的.php網頁;
//後端的實現方法
<?php
//這個class類是借鑑網友的,具體內部邏輯我也不太清晰,因此。。。。。。。
class zipfile {
var $datasec = array ();
var $ctrl_dir = array ();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
function unix2_dostime($unixtime = 0){
$timearray = ($unixtime == 0) ? getdate () : getdate($unixtime);
if ($timearray ['year'] < 1980){
$timearray ['year'] = 1980;
$timearray ['mon'] = 1;
$timearray ['mday'] = 1;
$timearray ['hours'] = 0;
$timearray ['minutes'] = 0;
$timearray ['seconds'] = 0;
}
return (($timearray ['year'] - 1980) << 25) | ($timearray ['mon'] << 21) | ($timearray ['mday'] << 16) | ($timearray ['hours'] << 11) | ($timearray ['minutes'] << 5) | ($timearray ['seconds'] >> 1);
}
function add_file($data, $name, $time = 0){
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2_dostime($time));
$hexdtime = '\x' . $dtime [6] . $dtime [7] . '\x' . $dtime [4] . $dtime [5] . '\x' . $dtime [2] . $dtime [3] . '\x' . $dtime [0] . $dtime [1];
eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04