<?php

include_once './db_functions.php'; 
$db = new DB_Functions(); 

$json = $_POST["ImageUpload"];

function filesize_dir($file) {
        exec('dir ' . $file, $inf);
        $size_raw = $inf[6];
        $size_exp = explode(" ",$size_raw);
        $size_ext = $size_exp[19];
        $size_int = (float) str_replace(chr(255), '', $size_ext);
        return $size_int;
    }

if (get_magic_quotes_gpc()){ 
		$json = stripslashes($json); 
	}

//Decode JSON into an Array 
$data = json_decode($json);



$temp=0;
$a=array();



for($i=0; $i<count($data) ; $i++) {
	$id=$data[$i]->_id;
    $b=array();


	$b["id"] = $id;          
	$b["status"] = 'yes'; 
	$temp++; // get  no of jobs for which images are uploaded 
    $base=$data[$i]->encodedString;
 
echo $base;
 // Get file name posted from Android App
    $filename = $data[$i]->fileName;

    $binary=base64_decode($base);
	$result = file_put_contents("feedbackImages/".$filename,$binary);
	
	
if($result=== FALSE) 
  die("Error writing data into $filename");
else
  echo "$result bytes written to $filename";
	

array_push($a,$b); 
}
  
 json_encode($a); 

?>
