<?php
include_once "../includes/connectConfig.php";

if(!empty($_FILES) && !empty($log_session)) { 

$crtss = (!isset($_SESSION['prdss'])) ? $_SESSION['prdss'] = rand() : $_SESSION['prdss'] = $_SESSION['prdss'];

$imagePath = isset($_FILES["file"]["name"]) ? $_FILES["file"]["name"] : "Undefined";
$sizea = $_FILES['file']['size'];$extsa = strtolower(pathinfo($imagePath, PATHINFO_EXTENSION));
$targetPath = "../img/"; $imagePath = $targetPath.$imagePath;
$tempFile = $_FILES['file']['tmp_name']; list($txta, $exta) = explode(".", $imagePath);
$fileName = date('ydmhis')."_".rand(1000,100000).'.'.$exta; $targetFile = $targetPath.$fileName;
if (move_uploaded_file($tempFile, $targetFile)) { 
$ins_img = $db_con->prepare("INSERT INTO sample_imageload(img_nm, img_post) VALUES (:imne, :imue)");
$ins_img->bindParam(':imne',$fileName); $ins_img->bindParam(':imue',$crtss); $ins_img->execute();
echo "true"; } else { echo "false"; } } ?>