我在Mongodb中使用php存储了超过250MB的压缩文件。但我无法找回它。它只显示我“0”号码。以下是我的代码。使用PHP从Mongodb下载大文件
$id = $_GET['id'];
require 'dbconnection.php';
$mongo = DBConnection::instantiate();
$gridFS = $mongo->database->getGridFS();
$object = $gridFS->findOne(array('_id' => new MongoId($id)));
header("Content-Transfer-Encoding: binary");
header('Content-type: '.$object->file['filetype']);
header('Expires: 0');
header("Content-disposition: attachment; filename=".$object->file['filename']);
//header('Content-name: '.$object->file['filename']);
header('Content-Type:application-x/force-download');
echo $object->getBytes();
检查它。这适用于小于100MB的文件。
它最有可能与使用所有可用内存有关。 – 2012-04-06 10:52:04