I want to get a picture from camera in android and to save it in server.I have used the below php code ,but it shows empty page
I want to get a picture from camera in android and to save it in server.I have used the below php code ,but it shows HTTP Error 414. The request URL is too long.page.Do my code is wrong.Why it is showing this error message My php code for storing image in db using php/sql server as below
<?php
require 'connect.php';
header('Content-type : bitmap; charset=utf-8');
if(isset($_POST["encoded_string"]))
{
$cust_name=$_POST["cust_name"];
$decoded_string =base64_decode($encoded_string);
$path= 'android/'.$cust_name;
$file=fopen($path,'wb');
$is_written=fwrite($file,$decoded_string);
fclose($file);
if($is_written >0)
{
$query = "UPDATE cust_detail SET img_url=? WHERE cusname=? ";
$params=array($path,$cust_name);
$result = sqlsrv_query($conn,$query,$params);
if( $result === false)
{
echo "Error in query preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}
else
{
echo "success";
}
sqlsrv_close($conn);
}
}
?>
My connect.php code is as below
<?php
$serverName = "******";//only the server name
$connectionInfo = array( "Database"=>"*****", "UID"=>"***", "PWD"=>"*****");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( !$conn ) {
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
I tested it in postman by Posting the values,it shows "HTTP Error 414. The request URL is too long.".Please can anyone help me ,it is quite urgent.Can you please tell me how to create a folder in php to store the images