如何使用php web服务将图像从android上传到mongodb
我正在从android上拍摄照片,并通过PHP web服务发送 我正在使用以下代码:-如何使用php web服务将图像从android上传到mongodb,php,android,mongodb,Php,Android,Mongodb,我正在从android上拍摄照片,并通过PHP web服务发送 我正在使用以下代码:- <?php //creating mongodb database connection $m = new MongoClient(); $db = $m->companydb; $grid= $db->getGridFS('myGrid'); //creating for request if($_SERVER['REQUEST_METHOD'] == 'POST') { $pic
<?php
//creating mongodb database connection
$m = new MongoClient();
$db = $m->companydb;
$grid= $db->getGridFS('myGrid');
//creating for request
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$pic = $_POST['image'];
//uploading in mongodb database
// we are getting error in this line -->This function work properly when
we are taking image from html file and use this command
//storeUpload('image'); but in this file first we are string in a variable
and then passing this variable using storeUpload function
// maybe thats why we are geeting this issue
$grid->storeUpload($pic);
echo "Successfully Uploaded";
}
else{
echo "please check the REQUEST_METHOD";
}
?>
谁能告诉我如何上传它。试着用它来发布到PHP。并且,您将要发布到PHP的内容是一个编码的。这是一种将图像发送到数据库并将其存储为字符串的简单方法。(使用~1.2x时,文件大小将更大)可能会重复