dai il lavoro di controllo al tuo file insert.php che fai prima....

e se il caso cancelli il file non desiderato ....


su server linux in php
basterebbe solo

if (file_exists($src)) {
$m = `file -b $src`;
return $m;
} else {
return "text/unknow";
}

window invece offre poco da quel lato....


Codice PHP:
/* return mime */
public static function Get($src) {
        
$extension substr($src,strrpos($src,".")+1);
        
        switch (
$extension) {
            case 
"rtf";
            return 
"text/rtf";
            case 
"sxw":
            case 
"odt":
            case 
"ods":
            case 
"sxc":
            return 
"application/vnd.sun.xml.writer";
            case 
"pdf":
            return 
"application/pdf";
            case 
"gif":
            return 
"image/gif";
            case 
"jpg":
            case 
"jpeg":
            return 
"image/jpeg";
            case 
"png":
            return 
"image/png";
            case 
"css":
            return 
"text/css";
            case 
"xml":
            case 
"xsl":
            case 
"xsd":
            case 
"rng":
            case 
"eps":
            case 
"ps":
            case 
"zip":
            case 
"sit":
            case 
"gz":
            case 
"tar":
            case 
"mp3":
            return 
"text/xml";
            case 
"js":
            return 
"text/javascript";
            case 
"html":
            case 
"htm":
            case 
"xhtml":
            return 
"text/html";
            case 
"txt":
            return 
"text/plain";
            
            default:
            if (
file_exists($src)) {
                
$m =  `file -b $src`;
                return 
$m;
            } else {
                return 
"text/unknow";
            }
        }
        
        
    }