function GestisciUpload($file_path = "models/")
{
    $allowed_type = array
    (
        'stl'   => 'application/octet-stream',
        'gif'   => 'image/gif',
        'jpeg'  => 'image/jpeg',
        'pjpeg' => 'image/pjpeg',
        'png'   => 'image/png',
//        'application/acad',
//        'application/dxf',
//        'application/iges',
//        'application/sla',
//        'application/vnd.ms-pki.stl',
//        'application/x-navistyle',
//        'image/vnd.dwg',
//        'image/x-dwg',
//        'model/iges',
//        'x-world/x-3dmf',
    );
    $UploadErrors = array
    (
        'There is no error, the file uploaded with success',
        'The uploaded file exceeds the upload_max_filesize directive in php.ini',
        'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
        'The uploaded file was only partially uploaded',
        'No file was uploaded',
        'Missing a temporary folder',
        'Failed to write file to disk',
        'A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help',
    );
    $err = $_FILES['fileToUpload']['error'];
    if ($err > 0 )
    {
        echo "ERRORE : ".( $err < 8 ? $UploadErrors[$err] : $err )."<br /><br />";
        return false;
    }
    // controllo se esiste la cartella di destinazione
    if ( !is_dir($file_path) )
    {
        echo "ERRORE : La cartella di destinazione non esiste<br /><br />";
        return false;
    }
    $file_name = $_FILES["fileToUpload"]["name"];             // nome originale del file ( Linux Unix : attenzione maiuscole e minuscole )
    $file_ext  = pathinfo($file_name, PATHINFO_EXTENSION);    // estensione del file caricato
    $file_type = strtolower($_FILES['fileToUpload']['type']); // mime type dal browser
    $file_size = $_FILES['fileToUpload']['size'] / 1024;      // dimensione in kB
    $file_temp = $_FILES['fileToUpload']['tmp_name'];         // file temporaneo, path e nome assegnato dall'upload
    $file      = $file_path.$file_name;                       // path di destinazione e nome originale del file
    // visualizzazioni da eliminare (commentare) in produzione
    echo "Upload : "        .$file_name."<br />";
    echo "extension : "     .$file_ext ."<br />";
    echo "Type : "          .$file_type."<br />";
    echo "Size (kB) : "     .$file_size."<br />";
    echo "Stored in : "     .$file_temp."<br />";
    echo "target folder : " .$file_path."<br />";
    echo "target file : "   .$file     ."<br />";
    // evito nomi di files con spazi intercalati
    if ( substr_count($file_name, ' ') )
    {
        echo "ERRORE : Il nome del file intercalato da spazi non è accettato. Rinomina il tuo file!<br /><br />";
        return false;
    }
    // controllo se posso ottenere "mime_type"
    if ( class_exists('finfo') )
    {
        $mime_type = ( new finfo(FILEINFO_MIME_TYPE) )->buffer( file_get_contents($file_temp) );
    }
    else if ( function_exists('mime_content_type') )
    {
        $mime_type = mime_content_type($file_temp);
    }
    else
    {
        echo "ERRORE : non posso ottenere 'mime_type' mancano gli strumenti php<br /><br />";
        return false;
    }
    $mime_type = strtolower($mime_type);     // per avere facilità nella gestione dell'array "allowed_type" ammesso ci siano maiuscole
    echo "MIME TYPE : ".$mime_type."<br />";
    // controllo se è accettabile
    if ( empty($allowed_type[$file_ext]) or $mime_type != $allowed_type[$file_ext] )
    {
        echo "ERRORE : Il file non è del tipo corretto.<br /><br />";
        return false;
    }
    // controllo la dimensione
    if ($file_size == 0)
    {
        echo "ERRORE : Il file è vuoto.<br /><br />";
        return false;
    }
    if ($file_size > 5000)
    {
        echo "ERRORE : Il file ha una dimensione troppo grande. Carica un file che non superi i 5 Mb.<br /><br />";
        return false;
    }
    // controllo se esiste lo stesso nome
    if ( file_exists($file) )
    {
        echo "ERRORE : Il nome scelto per il file esiste già. Rinomina il tuo file!<br /><br />";
        return false;
    }
    // sposto il file nella destinazione
    if ( !move_uploaded_file($file_temp, $file) )
    {
        echo "ERRORE : Lo spostamento del file nella destinazione non è riuscito"."<br /><br />";
        return false;
    }
    // controllo se il file é arrivato a destinazione
    if (!file_exists($file))
    {
        echo "ERRORE : Il file non è arrivato a destinazione<br /><br />";
        return false;
    }
    // non ho altro da fare
    echo "Il file -- ".$file_name." -- è stato caricato correttamente.";
    return true;
}