本文目录一览:
- 1、thinkphp打包exe
- 2、求大神帮把php文件给我打包成zip的、谢啦
- 3、php如何实现文件夹的打包下载详细操作步骤
- 4、php导出excel表后,打包成压缩包,然后下载到本地如何实现?
- 5、php 如何把文件夹及文件夹下面的所有文件打包成压缩包,在页面上用户点击下载按钮即可下载到本地?
thinkphp打包exe
thinkphp 打包文件,并下载
/**
* 打包下载
* 注意文件路径都是相对路径
* 不能使用ajax的方式
* @return [type] [description]
*/
public function allzip(){
$param = $this-request-param();
$ids = explode(",",$param['id']);
//要打包的文件
foreach ($ids as $k = $v){
$files[] =substr(db('seofile')-where('id',$v)-value('fileurl'),1);
}
$zip = new \ZipArchive;
//压缩文件名
$filename = 'upload/file/download.zip';
//新建zip压缩包
$zip-open($filename,\ZIPARCHIVE::OVERWRITE | \ZIPARCHIVE::CREATE);
//循环压缩文件
foreach($files as $key = $value){
$zip-addFile($value,basename($value));
}
//打包zip
$zip-close();
header("Cache-Control:public");
header("Content-Description: File Transfer");
header("Content-disposition: attachment; filename=".basename($filename));//文件名
//header("Content-Type: application/force-download");
header("Content-Type:application/zip"); //格式为zip
header("Content-Transfer-Encoding:binary"); //这是二进制文件
header("Content-Length:".filesize($filename)); //文件大小
@readfile($filename);
// @unlink($filename);
}
求大神帮把php文件给我打包成zip的、谢啦
1,程序操作:PHP的zip文件长传到附件了,放在网站的根目录就行了。
2,不同操作:选择PHP文件鼠标右键进行软件打包。
php如何实现文件夹的打包下载详细操作步骤
public function downloads(){
$file = "./Ludian_Disaster_Relief_Map_Operation_Guide.pdf";
if(file_exists($file)){
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
}else{
$this-error("文件不存在");
}
}
php导出excel表后,打包成压缩包,然后下载到本地如何实现?
用PHPExcel,PHPExcel是相当强大的 MS Office Excel 文档生成类库。
你上它的官/网把程序包下/载下来,里面有 PHPExcel 的程序、还有30个实例程序和三个文档。
看一下其中的开发文档你就会用了。
读取(这段在开发文档里有的,在13页):
require_once '../Classes/PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader-setReadDataOnly(true);
$objPHPExcel = $objReader-load("test.xlsx");
$objWorksheet = $objPHPExcel-getActiveSheet();
echo 'table' . "\n";
foreach ($objWorksheet-getRowIterator() as $row) {
echo 'tr' . "\n";
$cellIterator = $row-getCellIterator();
$cellIterator-setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
echo 'td' . $cell-getValue() . '/td' . "\n";
}
echo '/tr' . "\n";
}
echo '/table' . "\n";
?
php 如何把文件夹及文件夹下面的所有文件打包成压缩包,在页面上用户点击下载按钮即可下载到本地?
一般不会下载的时候重新打包,因为php打包是一个非常消耗资源的过程。
使用php zip 打包,然后记录包的路径,下载的时候直接下载该路径文件即可。