Bonjour à vous !
Comme di dans le sujet, je crée un script d'upload pour des images, sous firefox il marche parfaitement, sous IE il ne l'upload pas (par contre il enregistre bien toute les données dans la base de données dans les dernieres lignes de codes)
Y a t il des piege à éviter ?
Voila mon code
$fichierTemp = $_FILES['monFichier']['tmp_name'];
$fichierNom = $_FILES['monFichier']['name'];
$fichierType = $_FILES['monFichier']['type'];
$fichierErreur = $_FILES['monFichier']['error'];
$nomDestination = "../ImagesPost/".$fichierNom;
if ($fichierType=='image/gif'||$fichierType=='image/jpeg'||$fichierType=='image/png'||$fichierType=='image/jpg'||$fichierType=='image/JPG'||$fichierType=='image/JPEG')
{
if (!$fichierErreur)
{
if (is_uploaded_file($fichierTemp)AND!file_exists("../ImagesPost/".$fichierNom))
{
if(!move_uploaded_file($fichierTemp,$nomDestination))
{
echo ('impossible d\'enregister<br>');
}
else
{
$taille=getimagesize($nomDestination);
$source_image = imagecreatefromjpeg($nomDestination);
$pos_x=0;
$pos_y=0;
if ($taille[0]>=$taille[1])
{
$x = 205;
$y = (int)(($x*$taille[1])/$taille[0]);
$pos_y = (int)((205-$y)/2);
}
else
{
$y = 205;
$x = (int)(($y*$taille[0])/$taille[1]);
$pos_x = (int)((205-$x)/2);
}
$dest_image = imagecreatetruecolor(205,205);
$noir=imagecolorallocate($dest_image, 0, 0, 0);
imagecopyresampled($dest_image,$source_image, $pos_x,$pos_y,0,0,$x,$y,$taille[0] ,$taille[1]);
imagejpeg($dest_image,$nomDestination);
imagedestroy( $source_image);
imagedestroy( $dest_image);
}
}
else
{ }
}
else
{
echo ('désolé il y a eu une erreur <br>');
}
}
// On enregistre dans la BDD
mysql_query("INSERT INTO cri VALUES('', '" . $pseudo . "', '".$titre."', '" . $message . "','".$nomDestination."')");
}
Comme di dans le sujet, je crée un script d'upload pour des images, sous firefox il marche parfaitement, sous IE il ne l'upload pas (par contre il enregistre bien toute les données dans la base de données dans les dernieres lignes de codes)
Y a t il des piege à éviter ?
Voila mon code
$fichierTemp = $_FILES['monFichier']['tmp_name'];
$fichierNom = $_FILES['monFichier']['name'];
$fichierType = $_FILES['monFichier']['type'];
$fichierErreur = $_FILES['monFichier']['error'];
$nomDestination = "../ImagesPost/".$fichierNom;
if ($fichierType=='image/gif'||$fichierType=='image/jpeg'||$fichierType=='image/png'||$fichierType=='image/jpg'||$fichierType=='image/JPG'||$fichierType=='image/JPEG')
{
if (!$fichierErreur)
{
if (is_uploaded_file($fichierTemp)AND!file_exists("../ImagesPost/".$fichierNom))
{
if(!move_uploaded_file($fichierTemp,$nomDestination))
{
echo ('impossible d\'enregister<br>');
}
else
{
$taille=getimagesize($nomDestination);
$source_image = imagecreatefromjpeg($nomDestination);
$pos_x=0;
$pos_y=0;
if ($taille[0]>=$taille[1])
{
$x = 205;
$y = (int)(($x*$taille[1])/$taille[0]);
$pos_y = (int)((205-$y)/2);
}
else
{
$y = 205;
$x = (int)(($y*$taille[0])/$taille[1]);
$pos_x = (int)((205-$x)/2);
}
$dest_image = imagecreatetruecolor(205,205);
$noir=imagecolorallocate($dest_image, 0, 0, 0);
imagecopyresampled($dest_image,$source_image, $pos_x,$pos_y,0,0,$x,$y,$taille[0] ,$taille[1]);
imagejpeg($dest_image,$nomDestination);
imagedestroy( $source_image);
imagedestroy( $dest_image);
}
}
else
{ }
}
else
{
echo ('désolé il y a eu une erreur <br>');
}
}
// On enregistre dans la BDD
mysql_query("INSERT INTO cri VALUES('', '" . $pseudo . "', '".$titre."', '" . $message . "','".$nomDestination."')");
}