bonjour
ton code est mal organisé
<?php
$errors=null;
/*les tests*/
if(isset($_FILES['uploadFile'])){
$filename = $_FILES['uploadFile']['name'];
$path = pathinfo($filename);
echo $filesext = $path['extension'];
$filesext = strtolower($filesext);
$extensions_autorisees = array('jpg','jpeg','pjpg','pjpeg','jpg','png','gif','tiff');
$destpath = './uploads_img/';
if ($_FILES['uploadFile']['error'] <= 0){
}else{
$errors.='Erreur lors de l\'upload image';
exit($errors);
}
if ($_FILES['uploadFile']['size'] <= 2097152){
}else{
$errors.='L\'image est trop lourde';
exit($errors);
}
if(in_array($filesext,$extensions_autorisees)){
}else{
$errors.='Le type MIME de l\'image n\'est pas bon';
exit($errors);
}
$img = @getimagesize($_FILES['uploadFile']['tmp_name']);
if($filesext==='jpg' && ($img['mime']==='image/jpg' || $img['mime']==='image/jpeg' || $img['mime']==='image/pjpeg')){
$jpgimg = imagecreatefromjpeg($_FILES['uploadFile']['tmp_name']);
$tjpgimg = getimagesize($_FILES['uploadFile']['tmp_name']);
$newlarg = 350;
$newhaut = ( ($tjpgimg[1] * (($newlarg)/$tjpgimg[0])) );
$newjpgimg = imagecreatetruecolor($newlarg,$newhaut) or die ("Erreur");
imagecopyresampled($newjpgimg,$jpgimg,0,0,0,0,$newlarg,$newhaut,$tjpgimg[0],$tjpgimg[1]);
imagedestroy($jpgimg);
$filerename = 'fichier_du_'.date('YmdHis').'.'.$filesext;
imagejpeg($newjpgimg ,$destpath.$filerename,100);
}
elseif($filesext==='png' && ($img['mime']==='image/png' || $img['mime']==='image/x-png')){
$pngimg = imagecreatefrompng($_FILES['uploadFile']['tmp_name']);
$tpngimg = getimagesize($_FILES['uploadFile']['tmp_name']);
$newlarg = 350;
$newhaut = ( ($tpngimg[1] * (($newlarg)/$tpngimg[0])) );
$newpngimg = imagecreatetruecolor($newlarg,$newhaut) or die ("Erreur");
imagecopyresampled($newpngimg,$pngimg,0,0,0,0,$newlarg,$newhaut,$tpngimg[0],$tpngimg[1]);
imagedestroy($pngimg);
$filerename = 'fichier_du_'.date('YmdHis').'.'.$filesext;
imagepng($newpngimg, $destpath.$filerename,0);
}
elseif($filesext==='gif' && ($img['mime']==='image/gif')){
$pngimg = imagecreatefromgif($_FILES['uploadFile']['tmp_name']);
$tpngimg = getimagesize($_FILES['uploadFile']['tmp_name']);
$newlarg = 350;
$newhaut = ( ($tpngimg[1] * (($newlarg)/$tpngimg[0])) );
$newpngimg = imagecreatetruecolor($newlarg,$newhaut) or die ("Erreur");
imagecopyresampled($newpngimg,$pngimg,0,0,0,0,$newlarg,$newhaut,$tpngimg[0],$tpngimg[1]);
imagedestroy($pngimg);
$filerename = 'fichier_du_'.date('YmdHis').'.'.$filesext;
imagepng($newpngimg, $destpath.$filerename,0);
}
else{
}
}else{
}
?>
<html>
<head>
<script type="text/javascript">
<!--
function uploadInit() {
// Je pré-charge l'image
var oLoading = new Image();
oLoading.src = "loading.gif";
}
function uploadRun() {
document.getElementById("uploadStatus").innerHTML = "";
//document.getElementById("uploadSubmit").disabled = true;
return true;
}
function uploadEnd(sError, sPath) {
if(sError == 'OK') {
document.getElementById("uploadStatus").innerHTML = "téléchargement réussi!";
} else {
document.getElementById("uploadStatus").innerHTML = sError;
}
document.getElementById("uploadSubmit").disabled = false;
}
//-->
</script>
</head>
<form id="uploadForm" enctype="multipart/form-data" action="" target="uploadFrame"
onsubmit="uploadRun();" method="post" value="2097152">
</form>
<html>
Bonne programmation !