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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <?php
//Vérification de la premiere photo :
if (!empty($_FILES['photo']['size']))
{
//On définit les variables :
$maxsize = 10024; //Poid de l'image
$maxwidth = 100; //Largeur de l'image
$maxheight = 100; //Longueur de l'image
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'bmp' ); //Liste des extensions valides
if ($_FILES['photo']['error'] > 0)
{
$photo_erreur = "Erreur lors du transfert de l'avatar : ";
}
if ($_FILES['photo']['size'] > $maxsize)
{
$i++;
$photo_erreur1 = "Le fichier est trop gros : (<strong>".$_FILES['photo']['size']." Octets</strong> contre <strong>".$maxsize." Octets</strong>)";
}
$image_sizes = getimagesize($_FILES['photo']['tmp_name']);
if ($image_sizes[0] > $maxwidth OR $image_sizes[1] > $maxheight)
{
$i++;
$photo_erreur2 = "Image trop large ou trop longue :
(<strong>".$image_sizes[0]."x".$image_sizes[1]."</strong> contre <strong>".$maxwidth."x".$maxheight."</strong>)";
}
$extension_upload = strtolower(substr( strrchr($_FILES['photo']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$i++;
$photo_erreur3 = "Extension de la photo incorrecte";
}
}
$nomphoto=(!empty($_FILES['photo']['size']))?move_photo($_FILES['photo']):'';
// Insertion BDD
//On balance le tout dans notre table
mysql_query('
INSERT INTO arc_achat (bien, type, habimm, ville, ref, prix, surface, pieces, remarque, exclu, vendu, photo_energie, contenu, photo, photo_sup, time)
VALUES ("'.$bien.'" , "'.$type.'", "'.$habimm.'", "'.$ville.'", "'.$ref.'", "'.$prix.'", "'.$surface.'", "'.$pieces.'", "'.$remarque.'", "'.$exclu.'", "'.$vendu.'", "'.$photo_energie.'", "'.$contenu.'", "'.$nomphoto.'", "'.$temps.'") ') or die(mysql_error()); |
Partager