Wednesday, November 8, 2017

Send image from Android Application and Save image to my server direct from php file

 Send image from Android Application use bellow code 
a.Get picture from android
$OutLet_Picture = $_REQUEST['OutLet_Picture'];
b.Check Image isEmpty
$image_name1 = "none";

if(!empty($OutLet_Picture)){
  @$base64Data1=$_REQUEST['OutLet_Picture'];
  @$binary1=base64_decode($base64Data1);
  $image_name1= $date_time2."1001"."1". ".jpg";
C.Save the Image
//Get the file
$image_path='/var/www/example.com/public_html/New_Images/'.$image_name1;
//$content = file_get_contents($binary1);
//Store in the filesystem.
$fp = fopen($image_path, "w");
fwrite($fp, $binary1);
fclose($fp); 



}

Save image to my server direct from php file


Copy image to my server direct from URL [duplicate]

1.Use bellow code.
//Get the file
$content = file_get_contents("http://www.google.co.in/intl/en_com/images/srpr/logo1w.png");
//Store in the filesystem.
$fp = fopen("/location/to/save/image.jpg", "w");
fwrite($fp, $content);
fclose($fp);
2. Send image from Android Application use bellow code
a.Get picture from android
$OutLet_Picture = $_REQUEST['OutLet_Picture'];
b.Check Image isEmpty
$image_name1 = "none";

if(!empty($OutLet_Picture)){
  @$base64Data1=$_REQUEST['OutLet_Picture'];
  @$binary1=base64_decode($base64Data1);
  $image_name1= $date_time2."1001"."1". ".jpg";
C.Save the Image
//Get the file
$image_path='/var/www/example.com/public_html/New_Images/'.$image_name1;
//$content = file_get_contents($binary1);
//Store in the filesystem.
$fp = fopen($image_path, "w");
fwrite($fp, $binary1);
fclose($fp); 

}