PHP多文件下载 [英] PHP multiple file download

查看:140
本文介绍了PHP多文件下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 的PHP文档中看到了这个例子readfile

<?php
$file = 'monkey.gif';

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);
    exit;
}
?>

你如何使用它强制下载多个文件说 monkey.gif girraffe.jpg

How can you make it so It download multiple files say monkey.gif and girraffe.jpg

ZIP 文件...

推荐答案

你不能。这不是一个PHP限制,它是一个HTTP / Web浏览器限制。 HTTP不提供通过一个请求发送多个文件的机制。

You can't. It's not a PHP limitation, it's an HTTP/Web-Browser limitation. HTTP doesn't provide a mechanism for sending multiple files over one request.

然而,您可以创建一些PHP脚本来生成多个iframe,每个iframe将启动一个下载,并以这种方式假冒。

You could, however, have some PHP script that generates multiple iframes, which would initiate one download each, and fake it that way.

这篇关于PHP多文件下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆