Main issue is image file is not moving from temp location to new location. But it is not giving any error. And all mysql queries are working. Al the html part also working.
$newFileName = $_POST['filename'];
$imageTitle = $_POST['filetitle'];
$imageDesc = $_POST['filedesc'];
$file = $_FILES['file'];
$fileName = $file['name'];
$fileType = $file['type'];
$fileTempName = $file['temp_name'];
$fileError = $file['error'];
$fileSize = $file['size'];
$fileExt = explode(".",$fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array("jpg","jpeg","png");
if(in_array($fileActualExt,$allowed)){
if($fileError === 0){
if($fileSize < 20000000){
$imageFullName = $newFileName . "." . uniqid("",true) . "." . $fileActualExt;
$fileDestination = "../gallery/" . $imageFullName;
include_once 'dbh.inc.php';
if(!empty($imageTitle) || !empty($imageDesc)){
$sqlSelect = "SELECT * FROM gallery;";
$stmt = mysqli_stmt_init($conn);
if(mysqli_stmt_prepare($stmt,$sqlSelect)){
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$rowCount = mysqli_num_rows($result);
$setImageOrder = $rowCount+1;
$sqlInsert = "INSERT INTO gallery(title,description,imgfullname,ordergallery) VALUES(?,?,?,?);";
if(mysqli_stmt_prepare($stmt,$sqlInsert)){
mysqli_stmt_bind_param($stmt,"ssss", $imageTitle,$imageDesc,$imageFullName,$setImageOrder);
mysqli_stmt_execute($stmt);
move_uploaded_file($fileTempName, $fileDestination);
}
}
}
}
}
}