Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPzlib:如何从字符串变量动态创建内存中的zip文件?_Php_Dynamic_Zip_Zlib - Fatal编程技术网

PHPzlib:如何从字符串变量动态创建内存中的zip文件?

PHPzlib:如何从字符串变量动态创建内存中的zip文件?,php,dynamic,zip,zlib,Php,Dynamic,Zip,Zlib,这就是我需要的 $a=array('folder'=>'anyfolder','filename'=>'anyfilename','filedata'=>'anyfiledata'); 我需要使用$a中的压缩数据创建一个变量$zip,并使用 header('Content-type: application/octetstream'); echo $zip; 我找到的所有lib都会在磁盘上打包文件并创建zip文件。我需要使用内存动态地完成它。有没有关于如何使用纯php的zl

这就是我需要的

$a=array('folder'=>'anyfolder','filename'=>'anyfilename','filedata'=>'anyfiledata');
我需要使用$a中的压缩数据创建一个变量$zip,并使用

header('Content-type: application/octetstream');
echo $zip;
我找到的所有lib都会在磁盘上打包文件并创建zip文件。我需要使用内存动态地完成它。有没有关于如何使用纯php的zlib而不研究zip格式规范的例子


UPD:
这可以通过上课来完成吗

UPD:
对它可以=)

是的,由班级来做

require_once('CreateZipFile.php');
$zip = new CreateZipFile;
$zip->addFile('anyfiledata', 'anyfilename');
$zip->addFile('anyfiledata2', 'anyfolder/anyfilename.anyext');
$zip->addDirectory('anyemptydirwouldbecreatedinthiszipfile');
header('Content-disposition: attachment; filename='.'zipfile.zip'.'');
header('Content-type: application/octetstream');
echo $zip->getZippedfile();
die();

太好了,谢谢你。Rochak Chauhan

一个简单的解决方案是使用tmpfs创建一个ramdisk,并在其中处理拉链。