0

I'm taking the picture from android and sending via PHP web services.

I'm using this code:-

<?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"; 
}
?>

Can anybody please tell me how to upload it.

Renish Khunt
  • 5,620
  • 18
  • 55
  • 92
  • Possible duplicate of [Upload a file using PHP](http://stackoverflow.com/questions/35253550/upload-a-file-using-php) – node_modules Mar 27 '17 at 14:04

1 Answers1

0

Try to use GenericAsyncTask for POST to the PHP. And POST what you will post to the PHP is an encoded Bitmap to Base64. That's a simple way to send images to database and store them as a string. (The file size will be bigger with ~1.2x)

Community
  • 1
  • 1