1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| $content_dir ="../fichiers-maj/"; // dossier où sera déplacé le fichier
$tmp_file = $_FILES['fichier']['tmp_name'];
if( !is_uploaded_file($tmp_file) )
{
exit("Le fichier est introuvable");
}
// on vérifie maintenant l'extension
$type_file = $_FILES['fichier']['type'];
if(!strstr($type_file,'application/octet-stream') )
{
//application/octet-stream
exit("L'extention du fichier ne correspond pas");
}
// on copie le fichier dans le dossier de destination
$name_file = $_FILES['fichier']['name'];
if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
{
echo $_FILES['fichier']['error'];
exit("Impossible de copier le fichier dans $content_dir");
} |
Partager