I am using a PHP file as an API to upload photos to my app but the images are uploaded in a big size I need to reduce the image size but keep a good quality
I am using this code to upload photos
$imagearray = json_decode($_POST['img']);
foreach($imagearray as $value){
$data = explode(',', $value);
$imagedata = base64_decode($data[1]);
$nam = genRandomString().'.jpeg';
$target_path='../uploads/'.$nam;
file_put_contents($target_path,$imagedata);
if($imgsname=="")
{
$imgsname=$nam;
$imgname=$nam;
}
else
{
$imgsname=$imgsname.','.$nam;
}
}