dongxian0320 2017-03-27 14:25
浏览 60

php7.1存储文件并从mongdb 1.2.8中检索文件

Need help in dealing with files in php7.1 mongodb(1.2.8)

we are able to insert and fetch normal records(like id, name) in php7.1 mongodb1.28. need to know how we can store files and retrieve files in mongodb with php7.1

// 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 = "filename.txt";

// 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;

looking similar in php7.1

appreciates your help

thanks Naren

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记