0 ) {
$file = $_FILES['photos']['tmp_name'][0];
$name = $_FILES['photos']['name'][0];
$type = substr($name, (strrpos($name, '.')+1) );
$fileName = $filePath.'Photo_MaisonHote.'.$type;
if ( $_FILES['photos']['error'][0] == 'UPLOAD_ERR_OK' ) {
if ( $_FILES['photos']['size'][0] < 4000000 ) {
if ( is_uploaded_file($_FILES['photos']['tmp_name'][0] ) ) {
if ( file_exists('/home/maison/public_html/images/Photo_MaisonHote.gif') ) { $ext1 = 'gif'; }
if ( file_exists('/home/maison/public_html/images/Photo_MaisonHote.jpg') ) { $ext1 = 'jpg'; }
if ( file_exists('/home/maison/public_html/images/Photo_MaisonHote.jpeg') ) { $ext1 = 'jpeg'; }
if ( $ext1 ) {
unlink('/home/maison/public_html/images/Photo_MaisonHote.'.$ext1);
}
if (resize($file, $fileName, 345, 284, $type) ) {
$msg = '
Message
Modification de l\'image complétée avec succès';
}
}
}
}
else {
echo 'Une erreur est survenue durant le téléchargement de l\'image, veuillez réessayer. ';
}
}
if ( strlen( $_FILES['photos']['name'][1]) > 0 ) {
$name = $_FILES['photos']['name'][1];
$type = substr($name, (strrpos($name, '.')+1) );
$fileName = $filePath.'Photo_room.'.$type;
$file = $_FILES['photos']['tmp_name'][1];
if ( $_FILES['photos']['error'][1] == 'UPLOAD_ERR_OK' ) {
if ( $_FILES['photos']['size'][1] < 4000000 ) {
if ( is_uploaded_file($_FILES['photos']['tmp_name'][1] ) ) {
if ( file_exists('/home/maison/public_html/images/Photo_room.gif') ) { $ext2 = 'gif'; }
if ( file_exists('/home/maison/public_html/images/Photo_room.jpg') ) { $ext2 = 'jpg'; }
if ( file_exists('/home/maison/public_html/images/Photo_room.jpeg') ) { $ext2 = 'jpeg'; }
if ( $ext2 ) {
unlink('/home/maison/public_html/images/Photo_room.'.$ext2);
}
if (resize($file, $fileName, 242, 142, $type) ) {
$msg = 'Message
Modification de l\'image complétée avec succès';
}
}
}
}
else {
echo 'Une erreur est survenue durant le téléchargement de l\'image, veuillez réessayer.';
}
}
if ( strlen( $_FILES['photos']['name'][2] ) > 0 ) {
$name = $_FILES['photos']['name'][2];
$type = substr($name, (strrpos($name, '.')+1) );
$fileName = $filePath.'Photo_salon.'.$type;
$file = $_FILES['photos']['tmp_name'][2];
if ( $_FILES['photos']['error'][2] == 'UPLOAD_ERR_OK' ) {
if ( $_FILES['photos']['size'][2] < 4000000 ) {
if ( is_uploaded_file($_FILES['photos']['tmp_name'][2] ) ) {
if ( file_exists('/home/maison/public_html/images/Photo_salon.gif') ) { $ext3 = 'gif'; }
if ( file_exists('/home/maison/public_html/images/Photo_salon.jpg') ) { $ext3 = 'jpg'; }
if ( file_exists('/home/maison/public_html/images/Photo_salon.jpeg') ) { $ext3 = 'jpeg'; }
if ( $ext3 ) {
unlink('/home/maison/public_html/images/Photo_salon.'.$ext3);
}
if (resize($file, $fileName, 242, 140, $type) ) {
$msg = 'Message
Modification de l\'image complétée avec succès';
}
}
}
}
else {
echo 'Une erreur est survenue durant le téléchargement de l\'image, veuillez réessayer.';
}
}
if ( strlen( $_FILES['photos']['name'][3] ) > 0 ) {
$name = $_FILES['photos']['name'][3];
$type = substr($name, (strrpos($name, '.')+1) );
$fileName = $filePath.'Photo_montagne.'.$type;
$file = $_FILES['photos']['tmp_name'][3];
if ( $_FILES['photos']['error'][3] == 'UPLOAD_ERR_OK' ) {
if ( $_FILES['photos']['size'][3] < 4000000 ) {
if ( is_uploaded_file($_FILES['photos']['tmp_name'][3] ) ) {
if ( file_exists('/home/maison/public_html/images/Photo_montagne.gif') ) { $ext4 = 'gif'; }
if ( file_exists('/home/maison/public_html/images/Photo_montagne.jpg') ) { $ext4 = 'jpg'; }
if ( file_exists('/home/maison/public_html/images/Photo_montagne.jpeg') ) { $ext4 = 'jpeg'; }
if ( $ext4 ) {
unlink('/home/maison/public_html/images/Photo_montagne.'.$ext4);
}
if (resize($file, $fileName, 140, 284, $type) ) {
$msg = 'Message
Modification de l\'image complétée avec succès';
}
}
}
}
else {
echo 'Une erreur est survenue durant le téléchargement de l\'image, veuillez réessayer.';
}
}
if ( strlen( $_FILES['photos']['name'][4] ) > 0 ) {
$name = $_FILES['photos']['name'][4];
$type = substr($name, (strrpos($name, '.')+1) );
$fileName = $filePath.'5soleils.'.$type;
$file = $_FILES['photos']['tmp_name'][4];
if ( $_FILES['photos']['error'][4] == 'UPLOAD_ERR_OK' ) {
if ( $_FILES['photos']['size'][4] < 4000000 ) {
if ( is_uploaded_file($_FILES['photos']['tmp_name'][4] ) ) {
if ( file_exists('/home/maison/public_html/images/5soleils.gif') ) { $ext5 = 'gif'; }
if ( file_exists('/home/maison/public_html/images/5soleils.jpg') ) { $ext5 = 'jpg'; }
if ( file_exists('/home/maison/public_html/images/5soleils.jpeg') ) { $ext5 = 'jpeg'; }
if ( $ext5 ) {
unlink('/home/maison/public_html/images/5soleils.'.$ext5);
}
if (resize($file, $fileName, 58, 86, $type) ) {
$msg = 'Message
Modification de l\'image complétée avec succès';
}
}
}
}
else {
echo 'Une erreur est survenue durant le téléchargement de l\'image, veillez réessayer.';
}
}
}
function resize($filename, $dest, $width, $height, $typeOrig) { // reformatage dimage...
//$format = strtolower(substr(strrchr($filename,"."),1));
unset($msgImg);
switch($typeOrig) { // selection du type et creation de limage a modifier (create from)
case 'gif' :
$type ="gif";
$img = imagecreatefromgif($filename);
break;
case 'jpg' :
$type ="jpg";
$img = imagecreatefromjpeg($filename);
break;
case 'jpeg' :
$type ="jpg";
$img = imagecreatefromjpeg($filename);
break;
default :
$msgImg = 'Le type n\'est pas accepté, les types valides sont (gif, jpeg, jpg, png)';
break;
}
if ( !isset($msgImg) ) { // si la selection est accepter alors on continue sinon on arrete le script
list($org_width, $org_height) = getimagesize($filename); // acquisition de la taille actuelle
$xoffset = 0;
$yoffset = 0;
$xtmp = $org_width/$width; // calcul de redimensionnement
$new_width = $width;
$new_height = $org_height/$xtmp;
if ($new_height > $height){ // si trop haute on redimensionne
$ytmp = $org_height/$height;
$new_height = $height;
$new_width = $org_width/$ytmp;
}
$width = round($new_width);
$height = round($new_height);
$img_n= imagecreatetruecolor ($width, $height); // generation de limage
imagecopyresampled($img_n, $img, 0, 0, $xoffset, $yoffset, $width, $height, $org_width, $org_height);
if($type=="gif") {
imagegif($img_n, $dest);
}
elseif($type=="jpg") {
imagejpeg($img_n, $dest);
}
elseif($type=="png") {
imagepng($img_n, $dest);
}
elseif($type=="bmp") {
imagewbmp($img_n, $dest);
}
return true;
}else { // si invalide.. on renvoie le tout
return false;
}
}
?>
Webtactik - Espace clients
Modification des images de la page d'accueil