<?php
$timex = time();
$fileA = "file1";
$fileA_Title = 'Cover Image';
$uploaded_images = array();
//$total_images = count($_FILES[$fileA]['name']);
$total_images = 1;
$files = $_FILES[$fileA]['name'];
$filenames = "";
if(!empty($files)){
if($total_images<=1){
 	
$upload_dir = "../j_files/j_img/blog/"; 

$upload_file = $upload_dir.$_FILES[$fileA]['name'];
$filename = $_FILES[$fileA]['name'];
//
$ext = explode('.', basename($_FILES[$fileA]['name']));//explode file name from dot(.) 
$file_extension = strtolower(end($ext)); //store extensions in the variable
//
$validextensions = array("jpeg", "jpg", "png","gif","webp");  //Extensions which are allowed
if (in_array($file_extension, $validextensions)) {				
$extx = ".$file_extension";
//
$nom = $key+1; //file numbering for user to understand.
//$new_filename = "$transact_id$key$timex$extx"; //rename file
$new_filename = "$timex$id$key$extx"; //rename file
$upload_file = "$upload_dir$new_filename"; //rename file
if(move_uploaded_file($_FILES[$fileA]['tmp_name'], ''.$upload_file)){ //SAVE FILE
//$filenames .="".$new_filename.",";  
$filenames .="".$new_filename."";  
//}
}else{ 
	die("Unable to upload $fileA_Title. Please choose another.");
}
}else{ 
	die("$fileA_Title type is invalid, Please choose another.");
}
//} //end loop
}else{ 
	die("Please, you can only upload 1 $fileA_Title file at a time.");
}
}else{ 
	//if(empty($p_passport)){
		//die("<div class='alert alert-danger'>Please upload $fileA_Title</div>");
	//}
}
//$filenames = mb_substr($filenames,0,-1);
//echo $filenames;
?>