我在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