PHP打包下载整个文件夹或多文件

中国1990-2021连续30年土地利用CLCD数据分享 CLCD(China Land Cover Dataset)数据集是由武汉大学黄昕老师基于Google Earth Engine上的335,709景Landsat数据制作的中国年度土地覆盖数据集。为了提高CLCD的时空一致性,还提出了一种包含时空滤波和逻辑推理的后处理方法。该数据集最大的优势在于每年30米的土地利用分类结果,且连续覆盖了30年时间。相比其他产品如GLC_FCS30、Global30、AGLC2000_2015、FROM-GLC10、ESA10、ESRI10等,CLCD在时间分辨率上更高。 阅读详情

有时候需要输出服务器上某个文件夹的全部文件,比如备份网站,
用下面的PHP函数来实现。

函数库代码PHPZip为:(请复制以下代码保存,以供调用)

    <?php
    ClassPHPZip{
    Private$StrPath="../../@UpLoad";
    Private$datasec=array();
    Private$ctrl_dir=array();
    Private$eof_ctrl_dir="\x50\x4b\x05\x06\x00\x00\x00\x00";
    Private$old_offset=0;

    //压缩后下载
    FunctionDownLoad($curdir,$zipfilename,$out){
    $zipfilename=StrToLower($zipfilename);
    $curdir=Str_iReplace(basename($curdir),"",$curdir);
    chdir($curdir.$this->StrPath);

    header('Content-Encoding: none');
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment ; filename='.Str_Replace(".zip","",basename($zipfilename)).'.zip');
    header('Pragma: no-cache');
    header('Expires: 0');
    print($out);
    }

    //压缩后保存在服务器,默认在/@Upload下
    FunctionSaveFile($curdir,$zipfilename,$out){
    $curdir=Str_iReplace(basename($curdir),"",$curdir);
    chdir($curdir.$this->StrPath);
    $fp=fopen($zipfilename,"wb");
    fwrite($fp,$out,strlen($out));
    fclose($fp);
    }

    //函数用途:压缩文件夹,递归逐层进行
    //参数详解:$dir需要压缩的目录,$zipfilename压缩后的文件名及存放路径,$Todo处理方式1提供下载2保存文件在服务器
    FunctionZipDir($dir,$zipfilename,$Todo){
    IF(!@Function_exists('gzcompress')){Return0;}
    @set_time_limit("0");
    $this->openFile($dir,$zipfilename);
    $out=$this -> filezip();

    Switch($Todo){
    Case"1":
    $this ->DownLoad(__FILE__,$zipfilename,$out);
    Break;
    Case"2":
    $this ->SaveFile(__FILE__,$zipfilename,$out);
    Break;
    }
    }

    //函数用途:压缩文件,可以是单个也可以是数组的多个
    //参数详解:$file需要压缩的文件(可为数组),$zipfilename压缩后的文件名及存放路径,$Todo处理方式1提供下载2保存文件在服务器
    FunctionZipFile($file,$zipfilename,$Todo){
    IF(!@Function_exists('gzcompress')){Return0;}
    IF(is_array($file)){
    Foreach($fileas$filename){
    IF(is_file($filename)){
    $fd=fopen($filename,"rb");
    $content= @fread($fd,filesize($filename));
    fclose($fd);

    $filename=basename($filename);
    $this ->addFile($content,$filename);
    }
    }
    }Else{
    IF(is_file($file)){
    $fd=fopen($file,"rb");
    $content= @fread($fd,filesize($file));
    fclose($fd);
    $file=basename($file);
    $this ->addFile($content,$file);
    }
    }
    $out=$this ->filezip();

    Switch($Todo){
    Case"1":
    $this ->DownLoad(__FILE__,$zipfilename,$out);
    Break;
    Case"2":
    $this ->SaveFile(__FILE__,$zipfilename,$out);
    Break;
    }
    }

    //递归取得下层文件夹下的文件
    FunctionopenFile($path,$zipName){
    $temp_path=$path;
    $temp_zip_path=$zipName;
    IF($handle=@opendir($path)){
    While(false !== ($file=readdir($handle))){
    IF($file !='.'and$file !='..'){
    IF(ereg('\.' ,$file.@basename())){
    $fd=fopen($path.'/'.$file,"r");
    $fileValue=@fread($fd,1024000);
    fclose($fd);
    $this ->addFile($fileValue,$path.'/'.$file);
    }Else{
    $this ->openFile($path.'/'.$file,$zipName.'/'.$file);
    }
    }
    }
    $zipName=$temp_zip_path;
    $path=$temp_path;
    closedir($handle);
    }
    }

    FunctionaddFile($data,$name,$time=0){
    $name=str_replace('\\','/',$name);
    $name=str_replace('./','',str_replace('../','',$name));
    $dtime=dechex($this->unix2DosTime($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";
    $fr.="\x14\x00";
    $fr.="\x00\x00";
    $fr.="\x08\x00";
    $fr.=$hexdtime;

    $unc_len=strlen($data);
    $crc=crc32($data);
    $zdata=gzcompress($data);
    $c_len=strlen($zdata);
    $zdata=substr(substr($zdata,0,strlen($zdata) - 4),2);
    $fr.=pack('V',$crc);
    $fr.=pack('V',$c_len);
    $fr.=pack('V',$unc_len);
    $fr.=pack('v',strlen($name));
    $fr.=pack('v',0);
    $fr.=$name;
    $fr.=$zdata;
    $fr.=pack('V',$crc);
    $fr.=pack('V',$c_len);
    $fr.=pack('V',$unc_len);

    $this ->datasec[]=$fr;
    $new_offset=strlen(implode('',$this->datasec));

    $cdrec="\x50\x4b\x01\x02";
    $cdrec.="\x00\x00";
    $cdrec.="\x14\x00";
    $cdrec.="\x00\x00";
    $cdrec.="\x08\x00";
    $cdrec.=$hexdtime;
    $cdrec.=pack('V',$crc);
    $cdrec.=pack('V',$c_len);
    $cdrec.=pack('V',$unc_len);
    $cdrec.=pack('v',strlen($name));
    $cdrec.=pack('v',0);
    $cdrec.=pack('v',0);
    $cdrec.=pack('v',0);
    $cdrec.=pack('v',0);
    $cdrec.=pack('V',32);
    $cdrec.=pack('V',$this -> old_offset);
    $this ->old_offset=$new_offset;
    $cdrec.=$name;
    $this ->ctrl_dir[]=$cdrec;
    }

    Functionfilezip(){
    $data=implode('',$this -> datasec);
    $ctrldir=implode('',$this -> ctrl_dir);

    Return
    $data.$ctrldir.$this -> eof_ctrl_dir .
    pack('v',sizeof($this -> ctrl_dir)) . 
    pack('v',sizeof($this -> ctrl_dir)) . 
    pack('V',strlen($ctrldir)) . 
    pack('V',strlen($data))."\x00\x00";
    }

    Functionunix2DosTime($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);
    }

    /*
    解压缩部分
    用途:解压缩文件
    参数:$zn需要解压缩的zip文件及路径,$to解压缩的目的地
    */
    FunctionUnzip_File($zn,$to,$index =Array(-1)){
    $ok =0;
    $zip = @fopen($zn,'rb');
    IF(!$zip){Return(-1);}
    $cdir =$this ->ReadCentralDir($zip,$zn);
    $pos_entry =$cdir['offset'];

    IF(!is_array($index)){
    $index =array($index);
    }
    For($i = 0;$index[$i];$i++){
    IF(intval($index[$i])!=$index[$i] || $index[$i] > $cdir['entries']){Return(-1);}
    }

    For($i=0;$i<$cdir['entries'];$i++){
    @fseek($zip,$pos_entry);
    $header =$this ->ReadCentralFileHeaders($zip);
    $header['index'] = $i;
    $pos_entry =ftell($zip);
    @rewind($zip);
    fseek($zip,$header['offset']);
    IF(in_array("-1",$index) || in_array($i,$index)){$stat[$header['filename']] = $this ->ExtractFile($header,$to,$zip);}
    }
    fclose($zip);
    Return$stat;
    }

    //取得压缩包内的文件信息
    Functionget_List($zip_name){
    $zip = @fopen($zip_name,'rb');
    IF(!$zip){Return(0);}
    $centd =$this ->ReadCentralDir($zip,$zip_name);

    @rewind($zip);
    @fseek($zip,$centd['offset']);

    For($i=0;$i<$centd['entries'];$i++){
    $header =$this ->ReadCentralFileHeaders($zip);
    $header['index'] = $i;
    $info['filename'] = $header['filename'];
    $info['stored_filename'] = $header['stored_filename'];
    $info['size'] = $header['size'];
    $info['compressed_size'] = $header['compressed_size'];
    $info['crc'] = strtoupper(dechex($header['crc']));
    $info['mtime'] = $header['mtime'];
    $info['comment'] = $header['comment'];
    $info['folder'] = ($header['external'] == 0x41FF0010 ||$header['external'] == 16)?1:0;
    $info['index'] = $header['index'];
    $info['status'] = $header['status'];
    $ret[] = $info;
    unset($header);
    }
    Return$ret;
    }

    FunctionReadFileHeader($zip){
    $binary_data =fread($zip,30);
    $data =unpack('vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len',$binary_data);

    $header['filename'] = fread($zip,$data['filename_len']);
    IF($data['extra_len'] != 0){$header['extra'] = fread($zip,$data['extra_len']);}Else{$header['extra'] = '';}

    $header['compression'] = $data['compression'];
    $header['size'] = $data['size'];
    $header['compressed_size'] = $data['compressed_size'];
    $header['crc'] = $data['crc'];
    $header['flag'] = $data['flag'];
    $header['mdate'] = $data['mdate'];
    $header['mtime'] = $data['mtime'];

    IF($header['mdate'] && $header['mtime']){
    $hour =($header['mtime']&0xF800) >> 11;
    $minute =($header['mtime']&0x07E0) >> 5;
    $seconde =($header['mtime']&0x001F) * 2;
    $year =(($header['mdate']&0xFE00) >> 9) + 1980;
    $month =($header['mdate']&0x01E0) >> 5;
    $day =$header['mdate']&0x001F;
    $header['mtime'] = mktime($hour,$minute,$seconde,$month,$day,$year);
    }Else{
    $header['mtime'] = time();
    }

    $header['stored_filename'] = $header['filename'];
    $header['status'] = "ok";
    Return$header;
    }

    FunctionReadCentralFileHeaders($zip){
    $binary_data =fread($zip,46);
    $header =unpack('vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset',$binary_data);

    IF($header['filename_len'] != 0)
    $header['filename'] = fread($zip,$header['filename_len']);
    Else$header['filename'] = '';

    IF($header['extra_len'] != 0)
    $header['extra'] = fread($zip,$header['extra_len']);
    Else$header['extra'] = '';

    IF($header['comment_len'] != 0)
    $header['comment'] = fread($zip,$header['comment_len']);
    Else$header['comment'] = '';

    IF($header['mdate'] && $header['mtime']){
    $hour =($header['mtime'] &0xF800) >> 11;
    $minute =($header['mtime'] &0x07E0) >> 5;
    $seconde =($header['mtime'] &0x001F) * 2;
    $year =(($header['mdate'] &0xFE00) >> 9) + 1980;
    $month =($header['mdate'] &0x01E0) >> 5;
    $day =$header['mdate'] &0x001F;
    $header['mtime'] = mktime($hour,$minute,$seconde,$month,$day,$year);
    }Else{
    $header['mtime'] = time();
    }
    $header['stored_filename'] = $header['filename'];
    $header['status'] = 'ok';
    IF(substr($header['filename'], -1) == '/')
    $header['external'] = 0x41FF0010;
    Return$header;
    }

    FunctionReadCentralDir($zip,$zip_name){
    $size =filesize($zip_name);
    IF($size < 277){$maximum_size = $size;}Else{$maximum_size = 277;}

    @fseek($zip,$size -$maximum_size);
    $pos =ftell($zip);
    $bytes =0x00000000;

    While($pos < $size){
    $byte = @fread($zip,1);
    $bytes =($bytes << 8) | Ord($byte);
    IF($bytes == 0x504b0506){
    $pos++;
    break;
    }
    $pos++;
    }

    $data =unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size',fread($zip,18));

    IF($data['comment_size'] != 0){$centd['comment'] = fread($zip,$data['comment_size']);}Else{$centd['comment'] = '';}
    $centd['entries'] = $data['entries'];
    $centd['disk_entries'] = $data['disk_entries'];
    $centd['offset'] = $data['offset'];
    $centd['disk_start'] = $data['disk_start'];
    $centd['size'] = $data['size'];
    $centd['disk'] = $data['disk'];
    Return$centd;
    }

    FunctionExtractFile($header,$to,$zip){
    $header =$this ->readfileheader($zip);

    IF(substr($to, -1) != "/")$to .="/";
    IF(!@is_dir($to)) @mkdir($to,0777);

    $pth =explode("/",dirname($header['filename']));
    For($i = 0;isset($pth[$i]);$i++){
    IF(!$pth[$i])continue;
    $pthss .=$pth[$i] . "/";
    IF(!is_dir($to . $pthss)) @mkdir($to . $pthss,0777);
    }
    IF(!($header['external'] == 0x41FF0010) && !($header['external'] == 16)){
    IF($header['compression'] == 0){
    $fp = @fopen($to . $header['filename'],'wb');
    IF(!$fp)Return(-1);
    $size =$header['compressed_size'];

    While($size != 0){
    $read_size =($size < 2048 ?$size :2048);
    $buffer =fread($zip,$read_size);
    $binary_data =pack('a' . $read_size,$buffer);
    @fwrite($fp,$binary_data,$read_size);
    $size -=$read_size;
    }
    fclose($fp);
    touch($to . $header['filename'],$header['mtime']);
    }Else{
    $fp = @fopen($to . $header['filename'] . '.gz','wb');
    IF(!$fp)Return(-1);
    $binary_data =pack('va1a1Va1a1',0x8b1f,Chr($header['compression']),
    Chr(0x00),time(),Chr(0x00),Chr(3));

    fwrite($fp,$binary_data,10);
    $size =$header['compressed_size'];

    While($size != 0){
    $read_size =($size < 1024 ?$size :1024);
    $buffer =fread($zip,$read_size);
    $binary_data =pack('a' . $read_size,$buffer);
    @fwrite($fp,$binary_data,$read_size);
    $size -=$read_size;
    }

    $binary_data =pack('VV',$header['crc'],$header['size']);
    fwrite($fp,$binary_data,8);
    fclose($fp);

    $gzp = @gzopen($to . $header['filename'] . '.gz','rb')ordie("Cette archive est compress閑");
    IF(!$gzp)Return(-2);
    $fp = @fopen($to . $header['filename'],'wb');
    IF(!$fp)Return(-1);
    $size =$header['size'];

    While($size != 0){
    $read_size =($size < 2048 ?$size :2048);
    $buffer =gzread($gzp,$read_size);
    $binary_data =pack('a' . $read_size,$buffer);
    @fwrite($fp,$binary_data,$read_size);
    $size -=$read_size;
    }
    fclose($fp);
    gzclose($gzp);

    touch($to . $header['filename'],$header['mtime']);
    @unlink($to . $header['filename'] . '.gz');
    }
    }
    Returntrue;
    }
    }
    ?>

使用方法:

    函数:文件压缩
    压缩参数:需要压缩的文件或文件夹(文件可为数组),压缩后的zip文件名及存放路径,压缩类型1:文件夹2:文件,后续操作1:压缩后下载;2:存放在服务器上(默认为/@Upload下)
    压缩文件夹示例:Tozip("./","../".date("d-H-i-s").".zip",1,2);
    压缩文件示例:
    $aaa=array("../1.txt","../2.txt");
    Tozip($aaa,"../2.zip",2);

用法举例:
比如有这样一段文件结构:
home
--upload
----1.jpg
----2.jpg
----3.jpg
--web
----html
------inc
--------zip.php(这是上面的代码库)
------download.php

使用download.php中的代码,实现upload文件夹打包并自动下载:

    <?php

    FunctionTozip($Path,$ZipFile,$Typ=1,$Todo=1){
    //IF(!is_writeable($Path)){Exit("文件夹不可写!");}
    $Path=Str_iReplace("\\","/",($Path));
    IF(Is_Null($Path)OrEmpty($Path)Or !IsSet($Path)){ReturnFalse;}
    IF(Is_Null($ZipFile)OrEmpty($ZipFile)Or !IsSet($ZipFile)){ReturnFalse;}

    Include_once("inc/zip.php"); // 载入代码库,注意路径 
    $zip =NewPHPZip;
    IF(SubStr($Path,-1,1)=="/"){$Path=SubStr($Path,0,StrLen($Path)-1);}

    OB_end_clean();
    Switch($Typ){
    Case"1":
    $zip->ZipDir($Path,$ZipFile,$Todo);
    Break;
    Case"2":
    $zip->ZipFile($Path,$ZipFile,$Todo);
    Break;
    }

    IF($Todo==1){
    Die();
    }Else{
    ReturnTrue;
    }
    }

    Tozip("././upload","../../upload.zip",1,1)
    ?>

转载请保留链接:http://ilovetile.com/3074 感谢您对版权的尊重
//最然转载这个,但是个人认为这种相对路径,最好不要在上传下载的时候用,容易引发漏洞。能用绝对路径就用绝对路径…

R语言中的混淆矩阵(Confusion Matrix)是一种常用的评估多分类模型性能的工具 除了准确率,混淆矩阵还提供了其他有用的指标,如灵敏度(Sensitivity)、特异度(Specificity)、精确度(Precision)和召回率(Recall)。混淆矩阵通过比较模型预测结果与实际标签的一致性,帮助我们了解模型的分类准确性和错误类型。此外,混淆矩阵还提供了各种错误类型的统计信息,如假阳性(False Positive)和假阴性(False Negative)等。通过混淆矩阵,我们可以了解模型的整体性能和错误类型,从而对模型进行评估和改进。最后,为了更好地理解混淆矩阵的结果,可以使用。 阅读详情

相关推荐

Quartus Prime 软件 USB-blaster 驱动安装失败【已解决】

一、安装步骤 1、将FPGA 开发板插入电脑时,未安装驱动的电脑会提示安装usb-Blaster驱动。Windows搜索框打开设备管理器,在“其他设备”下会发现黄色感叹号的“USB-Blaster”的设备驱动。 2、Quartus系列软件的安装目录下自带USB-blaster的驱动程序,右键更新驱动,选择驱动目录:(D:\intelFPGA\18.1\quartus\drivers\usb-blaster,文件位置和版本请按照自己安装的路径选择),点击Next开始安装。 3、安装成功,重启电脑即可使

adolphwang_909086的博客 6万+

轻松实现!PHP目录文件一键打包压缩代码示例

打包工具

winkexin的博客 1331

别再为H5扫码头疼了!用Vue3 + vue-qrcode-reader,5分钟搞定移动端摄像头调用(附完整代码)

本文详细介绍了如何使用Vue3和vue-qrcode-reader快速实现移动端扫码功能,解决H5开发中常见的摄像头调用和兼容性问题。通过完整的代码示例和优化技巧,帮助开发者高效集成二维码识别功能,提升用户体验和开发效率。

weixin_33737134的博客 514

php打包文件夹

因公司业务需要,需要将学生上传的附件进行归类, 再将学生归到班级, 将班级归到年级,最后整合到学校一层。我们的客户是老师,不可能让他们自己一个附件一个附件的下载查看,那估计用户得崩溃。 现在基本上都用云存储了, 我们用的是七牛云。七牛提供了多文件压缩,但是下载之后解压缩会导致中文文件名乱码,向七牛官方反应过,但没有下文。那只能自己实现了。 php自带ZipArchive 类,打包就靠这个了。最简单...

weixin_30588827的博客 395

五、e2studio VS STM32CubeIDE之汉化

介绍stm32cubeide汉化方案和汉化包e2studio自带汉化包,在安装过程中可选择安装e2studio STM32CubeIDE切换中英文。

cl234583745的博客 1766

STM32 SAES硬件加密协处理器全模式工程实践指南

AES(高级加密标准)是嵌入式系统中最基础且关键的对称密码算法,其硬件加速实现直接影响安全、性能与功耗平衡。Secure AES Coprocessor(SAES)作为STMicroelectronics在STM32U5等高安全MCU中集成的专用密码协处理器,不仅支持标准ECB/CBC/CTR模式,更原生兼容GCM和CCM等认证加密模式,具备抗侧信道、密钥保护与DMA卸载能力。理解其寄存器状态机(CHMOD/MODE/CPHASE)、NPBLB数据对齐机制及GCM四阶段编程范式,是规避Tag校验失败、IV错

weixin_42311427的博客 76

php 打包文件代码

php将文件夹内容打包到指定文件夹。

x12301的博客 633

stm32h743 FM25CL64铁电存储器踩坑记录

调试FRAM经验总结: 1、跑完FRAM读写代码之后,逻分仪发现总线上只有简单、短暂的电平变化,明显不是SPI的通信数据。 (经提醒发现连片选拉高拉低都没有执行到位) 后来发现是因为片选引脚没有初始化,所以直接拉高拉低是无效的。 2、引脚成功初始化后发现CLK、MISO、MOSI数据仍不正常。通过加打印的方式发现跑到HAL_SPI_Transmit中之后还没有执行到写SPI数据寄存器的那一步就return了。 后来经提醒发现: 上图中的指针使用方式错误 后来又发现: 打印出来发现

kuniqiw的博客 3844

PHP 多文件打包下载方法

PHP 多文件打包下载方法

小洪帽i的博客 1541

python抓取美团外卖的数据(商家、评分、评论)

本文详细介绍了如何使用Selenium和抓取美团外卖的商家、评分和评论数据。我们从基础的爬虫原理入手,分析了美团外卖的网页结构,提出了应对反爬虫机制的策略,并给出了详细的代码实现。通过使用Selenium,我们能够绕过动态加载内容的限制,直接抓取网页中的商家信息和评论。结合多线程和代理池等技术,我们可以进一步提高爬虫效率,并避免IP被封禁。未来,随着爬虫技术的发展,我们可以进一步探索深度抓取、数据清洗和数据分析等高级应用,以实现更智能的网页数据抓取。

2201_76125261的博客 2700

树冠体积计算之体元累加法

因为是自己之前研究的一个方向,就复现了一下论文中的这个方法,在此正好记录一下。 文章目录一、简介二、代码实现(MATLAB)三、小结 一、简介 简而言之,其实就是一句话,即以固定大小的体元模拟不规则的树冠形状。按照论文中的思路主要就是将树冠沿树高方向以 k 为步长进行等距离分段,把每一段树冠的点投影到垂直于树高方向的平面上,再对该平面划分成大小为 k × k 的像元,根据投影到各个像元内点的数量,判断该像元的有效性,统计有效像元的数量 T,则树冠体积为 T 个 k × k × k 的体元之和。如下图所示:

dayuhaitang1的博客 2607

PHP ZipArchive打包文件夹及文件并下载

功能说明: 传入值(文件夹名称),判断是否文件夹存在 存在则打包该文件夹,并加入单个已有文件,加入自定义内容文件。 看点功能: 1.打包文件夹 2.打包单个文件 3.打包自定义文本内容文件 4.即时下载 5.缓存文件删除 6.自定义下载的zip文件名 功能示范:http://12391.net <?php $folder = $_GET['d']; //传递下载的文件夹名称 ...

易查薪 2532

通信模组性能调优

本文介绍了高通平台通信模组性能调优的方法,主要包括硬件加速技术和CPU负载优化。针对CPU负载优化,提出了内核RPS/RFS功能启用、网卡队列调整、中断均衡、CPU性能模式设置等措施。同时建议关闭热管理并加强散热,调整TCP接收/发送缓存大小以解决TCP异常报文问题。这些优化手段可显著提高整机吞吐率测试中的网络性能表现。

四儿家的小祖宗的博客 1359

php文件打包下载,php多文件打包下载的两种方法实例

最近整理文档,搜刮出一个php多文件打包下载的实例代码,稍微整理精简一下做下分享php多文件压缩并且下载。需要同时下载多个文件时,大部分浏览器都不支持多文件同时下载,可以采用JavaScript脚本动态生成多个链接,但是需要用户多次点击下载对话框,用户体验不好,并且有些浏览器还不兼容。此时多文件打包下载帮你解决这个问题。/*php多文件压缩并且下载*/function addFileToZip($...

weixin_28958239的博客 376

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

php 实现文件打包下载,php ZipArchive实现多文件打包下载实例

php ZipArchive实现多文件打包下载实例,文件,文件名,实例,文档,提示信息php ZipArchive实现多文件打包下载实例易采站长站,站长之家为您整理了php ZipArchive实现多文件打包下载实例的相关内容。实例代码:public function downLoad($dataUrl,$saveName) { $datalist = [ ROOT_PATH.'...

weixin_36378793的博客 209

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

php 文件夹打包_几行代码轻松实现PHP文件打包下载zip

本文实例为大家分享了PHP文件打包下载zip的具体代码,供大家参考,具体内容如下//获取文件列表function list_dir($dir){$result = array();if (is_dir($dir)){$file_dir = scandir($dir);foreach($file_dir as $file){if ($file == '.' || $file == '..'){con...

weixin_35654096的博客 885

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

php怎样打包下载文件,PHP打包下载多文件

PHP5.2+内置支持多文件打包,使用ZipArchive类。 要实现多文件打包下载,分两步,第一步是使用ZipArchive压缩多个文件,然后使用header指令生成下载操作。 第1步为了递归添加目录下所有子目录和文件,需要派生一个类,参考: 1.http://php.net/manual/en/claPHP5.2+内置支持多文件打包,使用ZipArchive类。要实现多文件打包下载,分两步,第...

weixin_34294809的博客 389

php 多文件压缩打包

php自带zip类库ziparchive <?php $zipname = './photo.zip'; //服务器根目录下有文件夹public,其中包含三个文件img1.jpg, img2.jpg, img3.jpg,将这三个文件打包下载,并重设下载的目录结构及文件名 file1/newimg1.jpg, file1/newimg2.jpg, file2/newimg.jpg $fi...

Ala的博客 636

php打包文件夹zip下载

需要用到php扩展ZipArchive 官网下载https://windows.php.net/downloads/pecl/releases/zip/ 我是 php5.6 nts版本 64位windows系统(linux不用dll) ,下载之后把php_zip.dll丢进php目录下ext文件夹里 在php.ini中添加一行extension=php_zip.dll重...

weixin_30455023的博客 281

PHP ZipArchive打包文件夹压缩下载

PHP 文件夹打包压缩下载 针对自己的环境扩展相应版本的php_zip;这里提供一个windows环境下php zip扩展下载地址:https://pecl.php.net/package/zip。 第一步 // 删除文件夹 function delDirFile($path) { $handler = opendir($path); //打开当前文件夹由$path指定。 if ($handler) { while (($filename = readdir($handle

突然空闲 974

php 文件夹打包_PHP实现打包zip并下载功能

具体代码如下所示:$file_template = FCPATH.'canddata/cand_picture.zip';//在此之前你的项目目录中必须新建一个空的zip包(必须存在)$downname = $card.'.zip';//你即将打包的zip文件名称$file_name = FCPATH.'canddata/'.$card.'.zip';//把你打包后zip所存放的目录$result...

weixin_39747975的博客 847

php打包/压缩文件夹为zip

因为有时候需要批量下载图片,所以需要进行压缩打包进行下载 可以用php自带的 ZipArchive 进行过操作 思路:可以先判断文件夹存不存在,存在调用核心方法进行处理 核心方法: /** * 压缩核心方法 * addtime 2020年7月17日 18:02:57 * @param [type] $dir 要压缩的文件路径 * @param [type] $zip ZipArchive的对象 * @return void */

Turbo 1007

php实现压缩文件打包下载功能的实践心得

今天刚刚实现了PHP的打包下载功能,古人言温故而知新,所以来记下一些遇到的问题和心得 首先PHP提供了一个ZipArchive拓展类供我们使用(这里不讨论如何获取这个拓展类),这个类里面内置了有关于zip文件相关的函数,一般的使用方法就是 $zip=new ZipArchive;//新建一个ZipArchive的对象 建立这个类对象之后我们就能调用方法为我们服务了,下面是搜集的一些大佬的常用功能...

weixin_41374749的博客 1149

PHP 打包文件下载

打包文件下载的主要思路: 在附件表中存的是文件的地址,地址存成这样****的: ./Public/Uploads/File/5d906c309e4bc.docx【注意前面的 . 】 1.指定压缩包的的名称 2.创建文件夹存放需要下载的文件(可指定文件的下载后的名称) 下载后的文件我用的原名称,这个点是需要改善的,不然解压压缩包后的文件名是一些被编码后的名称(像这样:5d906c309e4bc....

2250824907 423

php自动打包图片文件夹,PHP实现图片批量打包下载功能

上次遇到一个需要打包下载批量图片的问题,找了一下发现这个好方法,记录一下。首先新建一个zipfile打包类: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;functio...

weixin_39839018的博客 231

php依次下载多文件,php多文件下载的问题

这个其实有解决方案,通常的解决方案是将文件打包,然后将打包后的文件进行下载,就成为了一个压缩包.以前在弄网盘的时候,曾用过一个非常好用的包.用来生成压缩包的.Zippy,以下是一个示例,摘抄的:require __DIR__ . '/vendor/autoload.php';$zippy = Zippy::load();$archive = $zippy->create('archive.z...

weixin_39967996的博客 440
上一篇: Linux下中文文件名乱码问题的详解
下一篇: php导出excel表格
SunsCheung
博客等级 码龄11年 30粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值