par
Elie » 04 juin 2014, 13:46
Tu recuperes le type de fichier avec $_FILES['nom_du_champ']['type'] ...
Ca ne regarde pas l'extension mais bien la nature du fichier.
Après a toi de dire ce que tu tolères ou pas.
Voici des exemples de natures :
// on vérifie maintenant l'extension
$type_file = $_FILES['nom_du_champ']['type'];
$autorized = array(
'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/bmp', 'image/png', 'image/gif', // Fichier Image
'application/x-shockwave-flash', // Fichier SWF
'application/x-javascript', // Fichier JS
'text/html', 'application/octet-stream', // Fichier HTML
'application/x-zip', 'application/x-zip-compressed', 'application/zip', // Fichier Zip
'application/vnd.ms-excel', // Fichier Excel
'application/pdf', // Fichier PDF
'audio/mpeg', // Fichier Audio
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',// Fichier Word
'text/plain', // Fichier nfo / Txt
'application/srt', // Fichier sous-titres
'video/quicktime', // Fichier MOV
'video/x-flv', // Fichier FLV
'application/photoshop' // Fichier PSD
);
if(!in_array($type_file, $autorized)) {
echo "<br />Le type de fichier <strong>".$type_file."</strong> n'est pas une autorisé.\n";
} else {
Tu recuperes le type de fichier avec $_FILES['nom_du_champ']['type'] ...
Ca ne regarde pas l'extension mais bien la nature du fichier.
Après a toi de dire ce que tu tolères ou pas.
Voici des exemples de natures :
[php] // on vérifie maintenant l'extension
$type_file = $_FILES['nom_du_champ']['type'];
$autorized = array(
'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/bmp', 'image/png', 'image/gif', // Fichier Image
'application/x-shockwave-flash', // Fichier SWF
'application/x-javascript', // Fichier JS
'text/html', 'application/octet-stream', // Fichier HTML
'application/x-zip', 'application/x-zip-compressed', 'application/zip', // Fichier Zip
'application/vnd.ms-excel', // Fichier Excel
'application/pdf', // Fichier PDF
'audio/mpeg', // Fichier Audio
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',// Fichier Word
'text/plain', // Fichier nfo / Txt
'application/srt', // Fichier sous-titres
'video/quicktime', // Fichier MOV
'video/x-flv', // Fichier FLV
'application/photoshop' // Fichier PSD
);
if(!in_array($type_file, $autorized)) {
echo "<br />Le type de fichier <strong>".$type_file."</strong> n'est pas une autorisé.\n";
} else {
[/php]