<?php 
$generated_name = "";
 $hold_name = "";
if (isset($_FILES)) {
    //$generated_name .= $generated_name;

    // echo sizeof($_FILES);
      $temp = "";
     $tmp ="";
     $count=0;
    
      
      $i=0;

       foreach ($_FILES as $file){
         $i++;
               //$temp=$target;
        $filename = $file['name'];
        $file_tmp = $file['tmp_name'];
                

                $ext = explode('.', basename($filename)); //explode file name from dot(.) 
                $file_extension = end($ext); //store extensions in the variable
                $generated_name .= md5(uniqid()) . "." . $ext[count($ext) - 1];
                $tmp=$file_tmp;
                $count=$count + 1;
               // $temp=$temp.basename($filename);
             //$hold_name .= $generated_name;
                move_uploaded_file($tmp,"../../mail_attatchment/".$generated_name);
               

               
                // echo $tmp;
 //                 $values = array("user_id"=>$_SESSION['userid'],"photo"=>$generated_name);
 // $success = $userPhoto->insert($values);
 // if($success){
 //     echo "Saved";
 // }else{
 //     echo "Couldnt Save";
 // }
               
                
                
                $temp='';
                $tmp='';
            }

       
             
}
 
             echo $generated_name;      
 ?>