//image attribute is the name attribute in the Input File Field just as name that used for the Post Methode
// return array of errros
public function Controle_upload_file($file_field_name,$max_photo_uploading_size=10485760,$allow_exts=["JPG","GIF","PNG","JPEG"],$request_type="POST"){
//fix bytes shows
$errors=array();
if($_SERVER['REQUEST_METHOD'] == $request_type && isset($_FILES[$file_field_name])){
$name=$_FILES[$file_field_name]["name"];
$size=$_FILES[$file_field_name]["size"];
$type_file=explode("/",$_FILES[$file_field_name]["type"]);
$type=strtoupper(end($type_file));
$tmp_name=$_FILES[$file_field_name]["tmp_name"];
//check if user choosed a photo
if(empty($size)){$errors[]="You Must Choose A Photo ";}
else{
if(! in_array($type,$allow_exts)){$errors[]="Invalid File Format Must Be ".implode(",",$allow_exts);}
if($size>$max_photo_uploading_size){$errors[]="Too Large File the Size Must be under ". $max_photo_uploading_size." Bytes";}
}//end else
}else{$errors[]="Somthing Went Wrong";}
return $errors;
//end function
}
$errors=$function->Controle_upload_file("image"); //image attribute is the name attribute in the Input File Field just as name that used for the Post Methode