I am trying to upload multiple images in base64 format from my IONIC app using IONIC native camera plugin via PHP service. I successfully uploaded and decoded single image through the following way:
<?php
header("Content-Type: application/json");
require('confi.php');
define('UPLOAD_DIR', 'uploads/');
$target_file = $_POST['fileToUpload'];
$target_file = str_replace('data:image/png;base64,', '', $target_file);
$target_file = str_replace(' ', '+', $target_file);
$data = base64_decode($target_file);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
$myPic = 'http://yyyy .com/xxx/'.$file;
$sql = "insert into images(images) values('{$myPic}')";
How can I decode and upload multiple images like $image1,$image2,$image3,$image4 in database? I know I have to use foreach to loop the process but I tried several times but no luck. TIA