Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
if(count($resu_etu) > 0) {
 
	    //sauvegarde l'image en PNG	
            $image = base64_decode(substr($_POST['photo'], strpos($_POST['photo'], ",")+1));
            $fp = fopen(PHOTOS_DIR.$resu_etu[0]["numEtudiant"].'.png', 'wb');
            fwrite($fp, $image);
            fclose($fp);
	    //ouvre le PNG
    	    $imagepng = imagecreatefrompng(PHOTO_DIR.$result_etu[0]["numEtudiant"].'.png');
	    //convertit le PNG en JPG
	    imagejpeg($imagepng, PHOTO_DIR.$result_etu[0]["numEtudiant"].'.jpg', 100);
	    //détruit le PNG
            unlink(PHOTOS_DIR.$resu_etu[0]["numEtudiant"].'.png');
 
            echo "0";
    }
 
    else {
        $oDatabase->connectionSMS();
        $result_etu = $oDatabase->fetchDb($query);
        if(count($result_etu) > 0) { // => j'ai trouvé quelque chose
 
            //sauvegarde l'image en PNG 
            $image = base64_decode(substr($_POST['photo'], strpos($_POST['photo'], ",")+1));
            $fp = fopen(PHOTOS_DIR.$result_etu[0]["numEtudiant"].'.png', 'wb');
            fwrite($fp, $image);
            fclose($fp);
            //ouvre le PNG
            $imagepng = imagecreatefrompng(PHOTO_DIR.$resu_etu[0]["numEtudiant"].'.png');
            //convertit le PNG en JPG
            imagejpeg($imagepng, PHOTO_DIR.$resu_etu[0]["numEtudiant"].'.jpg', 100);
            //détruit le PNG
            unlink(PHOTOS_DIR.$result_etu[0]["numEtudiant"].'.png');
 
            echo "0";            
        }
        else {
            echo "1";
        }
    }
EDIT MODERATION : VEUILLEZ PRENDRE CONNAISSANCE DE CECI