3
어떻게 MongoDB에 파일을 저장할 수 있습니까?
내가 PHP를 사용하고 당신이 나에게 저장하고 난 아주PHP를 사용하여 MongoDB에 파일을 저장하는 방법은 무엇입니까?
어떻게 MongoDB에 파일을 저장할 수 있습니까?
내가 PHP를 사용하고 당신이 나에게 저장하고 난 아주PHP를 사용하여 MongoDB에 파일을 저장하는 방법은 무엇입니까?
확인이 튜토리얼 감사있을거야 그 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;
?>
다시 밖으로 파일을 얻으려면
그냥 좋습니다. 대단히 감사합니다 =) – fnaquira
위대한 ... 제발 getBytes의 사용을 말해 주시겠습니까 .... –