Пример #1
0
 $ListeExtensionIE = array('jpg' => 'image/pjpeg', 'jpeg' => 'image/pjpeg');
 if (!empty($_FILES['changer_avatar'])) {
     if ($_FILES['changer_avatar']['size'] != 0) {
         if ($_FILES['changer_avatar']['error'] <= 0) {
             if ($_FILES['changer_avatar']['size'] <= 2097152) {
                 $ImageNews = $_FILES['changer_avatar']['name'];
                 $ExtensionPresumee = explode('.', $ImageNews);
                 $ExtensionPresumee = strtolower($ExtensionPresumee[count($ExtensionPresumee) - 1]);
                 echo $ExtensionPresumee;
                 if ($ExtensionPresumee == 'jpg' || $ExtensionPresumee == 'jpeg') {
                     $ImageNews2 = getimagesize($_FILES['changer_avatar']['tmp_name']);
                     if ($ImageNews2['mime'] == $ListeExtension[$ExtensionPresumee] || $ImageNews2['mime'] == $ListeExtensionIE[$ExtensionPresumee]) {
                         $ImageChoisie = imagecreatefromjpeg($_FILES['changer_avatar']['tmp_name']);
                         include 'modele/image/modifications_image.php';
                         //$NouvelleImage = make_profile_square($ImageChoisie, 50);
                         $LienImageNews = make_tous_profiles($ImageChoisie);
                         // On écrit le potin dans la table "potins"
                         $req = $bdd->prepare('UPDATE users SET avatar = ? WHERE id_user = ?');
                         $req->execute(array($LienImageNews, $id_user));
                         $req->closeCursor();
                     } else {
                         echo 'Le type MIME de l\'image n\'est pas bon';
                     }
                 } else {
                     echo 'L\'extension choisie pour l\'image est incorrecte';
                 }
             } else {
                 echo 'L\'image est trop lourde';
             }
         } else {
             echo 'Erreur lors de l\'upload image';
Пример #2
0
<?php

include 'modele/image/modifications_image.php';
set_time_limit(0);
echo 'Debut conversion ...<br>';
// Pour chaque user
$req = $bdd->prepare('SELECT * FROM users where id_user = 90');
$req->execute();
while ($donnees = $req->fetch()) {
    echo $donnees['prenom'] . ' ';
    // Si il a une photo de profil
    if ($donnees['avatar'] != '') {
        $source = imagecreatefromjpeg($donnees['avatar']);
        // Chargement de la photo
        $nom_image = make_tous_profiles($source);
        //Conversion de la photo
        // Rentrage du nom dans la bdd
        $req2 = $bdd->prepare('UPDATE users SET avatar = ? WHERE id_user = ?');
        $req2->execute(array($nom_image, $donnees['id_user']));
        $req2->closeCursor();
        echo 'OK';
    }
    echo '<br>';
}
$req->closeCursor();
echo 'Terminé !';