<?php
$img_url = "";
$valid_formats = array("jpg", "png", "gif", "bmp","jpeg","pdf","xls","xlsx");

for($i=1;$i<5;$i++){
$name_file 			= $_FILES['img_file_'.$i]['name'];
$size_file 			= $_FILES['img_file_'.$i]['size'];

$upload_status = 0;
if(strlen($name_file))
{
$file_ext = getExtension($name_file);

if(in_array(strtolower($file_ext),$valid_formats))
{
$img_rul = "";	
$path 				= "../../../image/product/";
$location 			= "image/product/";
$actual_image_name 	= "";
$tmp 				= $_FILES['img_file_'.$i]['tmp_name'];
$kodefile 			= "img-".$autoid."-".$i;

		$actual_image_name = $kodefile.".".$file_ext;
		

		if(move_uploaded_file($tmp, $path.$actual_image_name)){
				$fileloc = $location.$actual_image_name;
				$upload_status = 1;

				
					$sql_upload = "UPDATE mst_product SET 
								image_url_$i = '$fileloc' 
								WHERE pm_autoid = '$autoid'";
					$conn->query($sql_upload) or die($sql_upload);
				}
			else{
				echo "Gagal Upload";	
				return false;			
				}
}
else
	echo "Invalid file format..";
	}
}

?>