Error on Upload image and also the uploaded image will update the database for changing profile picture (PHP)

uploadImage(){
if(this.clickedImagePath = null){
this.presentToast(“Don’t leave any field.”);
}

else{
  const actionSheet = this.actionSheetCtrl.create({
    title: 'Update changes?',
    buttons: [
      {
        text: 'Yes',
        handler: () => {
          let loader = this.loadingCtrl.create({
            content: "Uploading..."
          });
          loader.present();


    let completeUrl = this.url;
    let postData = new FormData()
    postData.append('file', this.clickedImagePath, this.userid);
    let data:Observable<any> = this.http2.post(completeUrl, postData);
    data.subscribe((result) => {
      console.log(result);
      alert("Success");
      loader.dismiss();
    }, (err) => {
      console.log(err);
      alert("Error");
      loader.dismiss();
    });
  }
},{
  text: 'Cancel',
  role: 'cancel',
  handler: () => {
    console.log('Cancel clicked');
  }
}

]
});
actionSheet.present();
}
}

This is my code for uploading image to the server

<?php $data = [ 'result' => false]; $target_path = time().'.jpg'; if (isset($_POST['file'])) { $img = mysqli_real_escape_string($con, $_REQUEST['img']); $id = mysqli_real_escape_string($con, $_REQUEST['id']); $sql1 = mysqli_query($con,"SELECT * from sl_user where u_id = '".$id."'"); $row=mysqli_fetch_array($sql1); $imgs = $row['u_image']; $sql4 = "UPDATE sl_user SET u_image='".$img."' WHERE u_id='".$id."'"; if(mysqli_query($con,$sql4)) { $row_array['type'] = "sucess"; die(json_encode($row_array)); } else{ $row_array['msg'] = 'Ooops - something went wrong: '.mysqli_error($con); $row_array['type'] = "error"; die(json_encode($row_array)); } $imagedata = $_POST['file']; $imagedata = str_replace('data:image/jpeg;base64','', $imagedata); $imagedata = str_replace('data:image/jpg;base64','', $imagedata); $imagedata = str_replace(' ','+', $imagedata); $imagedata = base64_decode($imagedata); file_put_contents($target_path, $imagedata); $data['result'] = true; $data['image_url'] = 'http://slcal.net/images/'.$target_path; } header('Access-Control-Allow-Origin: *'); header('Content-Type: application/json'); echo json_encode($data); ?>

This is the php server code

It will not upload and also update the database.
I would appreciate those who help me with this error. Thanks