<?php
	// config
	$imgnumber = 1;
	$updir = $photo_path_admin;
	$msg = "";
	$fupdir = "";
	$nimage_name = date("Y_m_d_H_i_s");
	// function
	for($i=1;$i<=$imgnumber;$i++)
	{
		$imglink[$i] = "";
		//////////////
		if(is_uploaded_file($_FILES['img'.$i]['tmp_name']))
		{ 
			// $imagestest = "no";
			// config
			$photo = $_FILES['img'.$i]['tmp_name'];
			$name  = $_FILES['img'.$i]["name"];
			// width and height
			$imgsize = GetImageSize($photo);
			// image kb
			$imgkb = filesize($photo);
			$imgurl_size_limitkb = $imgfsize[$page_name] * 1024;
			// file ext
			$array = explode(".", $name);
			$nr    = count($array);
			$pext  = $array[$nr-1];
			$pext = strtolower($pext);
			// check image format
			if(($pext == $imgf1) || ($pext == $imgf2) || ($pext == $imgf3))
			{
				if(($imgsize[0] > $imgfw2[$page_name]) || ($imgsize[0] < $imgfw1[$page_name]) || ($imgsize[1] > $imgfh2[$page_name]) || ($imgsize[1] < $imgfh1[$page_name]) || ($imgsize[0] == "") || ($imgsize[1] == ""))  
				{
	    			$msg .= "Image (".$i.") - Correct width and height - ".$imgfw1[$page_name]."-".$imgfw2[$page_name]."x".$imgfh1[$page_name]."-".$imgfh2[$page_name]."px.<br>";
				}
				
				if($imgkb > $imgurl_size_limitkb)  
				{
	    			$msg .="Image (".$i.") - Maximum size - ".$imgfsize[$page_name]."Kb.<br>";
				}    			 
			}
			else
			{
	    		$msg .= "Image (".$i.") - Incorrect format<br>"; 
			}
			// upload image function
			if($msg == "")
			{
				// image url
				$upname = $nimage_name."_".$i.".".$pext;
				$fupdir = $updir.$upname;
				// upload image two
				if(move_uploaded_file($photo, $fupdir)) 
				{
					// upload file
					$imglink[$i] = $upname; 
				}
				else
				{
					$msg .= "Image (".$i.") - Not uploaded<br>";
				}
			}
			// check error
			if($msg != "")
			{
				$imagestest = "no";
			}
			else
			{
				$imagestest = "yes";
			}
		}
		//////////////
	}
	
?>