2012-02-29 7 views

답변

12

확인이 튜토리얼 감사있을거야 그 FLES를 다운로드하는 방법을 알고 몇 가지 예를 들어 줄 coud 경우는 .. 어떤 정보로도
을하지 않는 것 아웃 : http://learnmongo.com/posts/getting-started-with-mongodb-gridfs/

이 몇 가지 코드를 붙여 질문에 대해 답을해야합니다 :

<?php 
// Connect to Mongo and set DB and Collection 
$mongo = new Mongo(); 
$db = $mongo->myfiles;  

// GridFS 
$gridFS = $db->getGridFS();  

// Find image to stream 
$image = $gridFS->findOne("chunk-screaming.jpg"); 

// Stream image to browser 
header('Content-type: image/jpeg'); 
echo $image->getBytes(); 

?> 
:

<?php 

// Connect to Mongo and set DB and Collection 
$mongo = new Mongo(); 
$db = $mongo->myfiles; 

// GridFS 
$grid = $db->getGridFS(); 

// The file's location in the File System 
$path = "/tmp/"; 

$filename = "03-smbd-menu-screen.mp3"; 

// Note metadata field & filename field 
$storedfile = $grid->storeFile($path . $filename, 
      array("metadata" => array("filename" => $filename), 
      "filename" => $filename)); 


// Return newly stored file's Document ID 
echo $storedfile; 

?> 

다시 밖으로 파일을 얻으려면

+0

그냥 좋습니다. 대단히 감사합니다 =) – fnaquira

+0

위대한 ... 제발 getBytes의 사용을 말해 주시겠습니까 .... –

관련 문제