<?php 
switch($_POST['action']){
    case "getfile":
        $nb=count($_FILES['files']['name']);
        for($i=0;$i<$nb;$i++){
            $accept=str_replace(".","",$_POST['accept']);
            $accept=explode(",",$accept);
            $filename=$_FILES['files']['name'][$i];

            $fileinfo=pathinfo($filename);

            $ext = strtolower($fileinfo['extension']);
            if($ext=="jpeg"){ $ext="jpg"; }

            if (!in_array($ext, $accept)) { 
                continue; 
            } 
            // Sauver le fichier dans le dossier temp
            // limiter la longueur du nom de fichier
            $filenamebase=substr(stripAccents($fileinfo['filename']),0,23);
            $filename = $filenamebase."_".uniqid().".".$ext; 
            
            move_uploaded_file($_FILES['files']['tmp_name'][$i],TEMP.$filename); 

            $name=$_POST['tagname'];
            $addtype=($_POST['multiple']=="null" ? "" : "[]");

            $pref=str_replace(CHEMIN,"",TEMP);

            $file=$filename;
            $description="";


            $sourceitem="";
            include(APP."form_parts/file-part.php");   
        }
        break;
} 