I uploaded image to the server using php.And i also generate a random image number after the id.Now the name of the uploaded image like 6_1.jpg, 5_4.jpg etc, Where 1st number is the id (before _) and other is randomly generated number(after _). My codes are as below
function upload_receipt_img(){
$random_digit = rand(0,9);
$receipt_id = $_POST['id'];
if (isset($_POST['data_url'])) {
$file = $receipt_id._.$random_digit.'.jpg';
$img = substr($_POST['data_url'], strpos($_POST['data_url'], ",") + 1);
$decodedData = base64_decode($img);
$success = file_put_contents('assets/receipt_img/' . $file, $decodedData);
//resize main image
$source_path = "assets/receipt_img/" . $file;
$destination = "assets/receipt_img/" . $file;
$newwidth = 350;
$this->resizeImg($newwidth, $source_path, $destination);
$data['img'] = 'assets/receipt_img/' . $receipt_id.$random_digit.'.jpg';
}
$this->closeConnection();
echo $receipt_id;
}
Now how can i show images from the server to my home page.Please help me.Thanks in advance