[英]how to upload file and store it in mongodb?
在此示例中,“路径”是服务器中(上传的)临时文件的路径吗? 或客户端设备中的文件路径? 我正在从$ _FILES中读取文件元数据,但不知道从哪里读取文件以存储在db中。 请帮忙。 (对不起我的英语不好)
<?php
// connect to the ‘myGrid’ GridFS
$m = new Mongo();
$db = $m->myDB;
$myGrid = $db->getGridFS('myGrid');
$some_file='path of your video or audio file';
// some extra data you may want to store with your file
$data_array = array(
'mime' => mime_content_type($some_file),
'timestamp' => time(),
);
// store a file into the GridFS
$myGrid->storeFile($some_file, $data_array);
?>
它是您要放入任何文件的路径,在这种情况下,它将是PHP $_FILES
数组中的tmp_name
路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.