Bonsoir,
Tout d'abord, désolé si je ne post pas dans la bonne section.
Mon soucis est surement tout bête mais je n'arrive pas à faire une redirection après une redimensionnement d'image.
J'upload une image sur le serveur, je créé la vignette associée, puis je voudrais faire une redirection...
Voici tout d'abord la fonction d'upload :
fichier: mesfonctions.php
Voici un exemple d'utilisation:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 <?php include("../connect.php"); // exemple $cheminGrandImage : C:\toto\normales\monImage.jpg // exemple $cheminVignette : C:\toto\miniatures\monImage.jpg // exemple $extension : png function CreerVignette($cheminGrandeImage,$cheminVignette,$extension) { switch ($extension) { case "png" : header ("Content-type: image/png"); $image = imagecreatefrompng($cheminGrandeImage); break; case "jpeg,jpg" : header('Content-type: image/jpeg'); $image = imagecreatefromjpeg($cheminGrandeImage); break; case "" : header('Content-type: image/jpeg'); $image = imagecreatefromjpeg($cheminGrandeImage); break; } $dimension=getimagesize($cheminGrandeImage); $largeur=$dimension[0]; $hauteur=$dimension[1]; $tailleMaxi = max($largeur, $hauteur); // Calculate offset of square portion of image // offsets will both be zero if original image is square $deltaX = ($tailleMaxi - $largeur)/2; $deltaY = ($tailleMaxi - $hauteur)/2; $destination = imagecreatetruecolor($tailleMaxi, $tailleMaxi); //Image qui sera l'image de destination $destinationbis = imagecreatetruecolor(87, 87); //Image qui sera l'image de destination $largeur_src = imagesx($image); //Renvoie la largeur de l'image source $hauteur_src = imagesy($image); //Renvoie la hauteur de l'image source imagecopyresampled($destination, $image, $deltaX, $deltaY, 0, 0, $largeur, $hauteur, $largeur_src, $hauteur_src); imagecopyresampled($destinationbis, $destination, 0, 0, 0, 0, 87, 87, $tailleMaxi, $tailleMaxi); switch ($extension) { case "png" : imagepng($destinationbis,$cheminVignette); break; case "jpeg,jpeg" : imagejpeg($destinationbis,$cheminVignette); break; } imagedestroy($image); imagedestroy($destination); } function upload($nomPhoto,$destinationDossier) { $erreurExtension="Seules les extensions suivantes sont autorisées: png, jpeg, jpg."; $erreurTaille="Le poids de l'image ne peut excéder 300Ko."; $erreurImage="Le fichier n'existe pas."; $nomPhoto=strtolower($nomPhoto); $extensionsValide = array('png','jpeg','jpg'); $tailleMax = 300000; //$destinationDossier = '../images/'; //Test1: fichier correctement uploadé if (isset($_FILES['photo']) and ($_FILES['photo']['name']!=NULL)) { if ($_FILES['photo']['size'] <= $tailleMax) { $extension = strtolower(substr(strrchr($_FILES['photo']['name'],'.'),1)); if (in_array($extension,$extensionsValide)) { $_FILES['photo']['name']= $nomPhoto; $destinationFichier = basename($_FILES['photo']['name']); $destinationFichier = strtr($nomPhoto, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy'); global $cheminImage; $cheminImage='../photos/'.$destinationDossier.'/galeries/photos/'.$destinationFichier; global $cheminVignette; $cheminVignette='../photos/'.$destinationDossier.'/galeries/photos/miniatures/'.$destinationFichier; //$destinationFichier=utf8_encode($destinationFichier); //$destinationFichier = preg_replace('/([^.a-z0-9]+)/i', '-', $destinationFichier); //genere_miniature('./'.$cheminImage,$extension); //$destinationFichier=utf8_encode($destinationFichier); move_uploaded_file($_FILES['photo']['tmp_name'], $cheminImage); CreerVignette($cheminImage,$cheminVignette,$extension); return true; } else { return $erreurExtension; } } else { return $erreurTaille; } } else { return "Aucun fichier image sélectionné pour l'upload."; } } ?>
Et l'erreur :
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 <?php include("mesfonctions.php"); include("../connect.php"); if(isset($_POST['btnValider'])) { $cheminImage=""; $cheminVignette=""; $reussi=upload($_FILES['photo']['name'],"parcours_images"); if(!is_string($reussi)) { $cheminImage = strtr($cheminImage, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy'); mysql_connect($serveur,$login,$mdp); mysql_select_db($bd); $sql='INSERT INTO photo (commentairePhoto,cheminPhoto,cheminVignette,rubriquePhoto) VALUES ("'.mysql_real_escape_string(htmlspecialchars($_POST['commentaire'])).'","'.mysql_real_escape_string(htmlspecialchars($cheminImage)).'","'.mysql_real_escape_string(htmlspecialchars($cheminVignette)).'","parcours_images")'; mysql_query($sql); header("location: upload_reussi_parcours_image.php"); } else { include("entete.php"); ?> <div id="corps"> <p class="corps_presentation">Ajouter une photo pour <i>Mon Parcours en Images</i></p> <?php if(isset($reussi)) echo $reussi; ?> <form action="ajouter_photo_parcours_image.php" method="post" enctype="multipart/form-data"> <p> <label>Photo:</label><br /> <input type="file" name="photo" id="photo" size=74 /> <input type="button" name="annuler" value="Annuler" onclick="document.getElementById('photo').value = '';" /> </p> <p> <label>Commentaire de la photo:</label><br /> <input type="text" name="commentaire" size=100></textarea> </p> <p> <input type="submit" name="btnValider" value="Uploader la photo" /> </p> </form> </div> <?php include("pied_de_page.html"); } } else { include("entete.php"); ?> <div id="corps"> <p class="corps_presentation">Ajouter une photo pour <i>Mon Parcours en Images</i></p> <form action="ajouter_photo_parcours_image.php" method="post" enctype="multipart/form-data"> <p> <label>Photo:</label><br /> <input type="file" name="photo" id="photo" size=74 /> <input type="button" name="annuler" value="Annuler" onclick="document.getElementById('photo').value = '';" /> </p> <p> <label>Commentaire de la photo:</label><br /> <input type="text" name="commentaire" size=100></textarea> </p> <p> <input type="submit" name="btnValider" value="Uploader la photo" /> </p> </form> </div> <?php include("pied_de_page.html"); } ?>
Le message est on ne peut plus clair Il aime pas la présence du header de redirection une fois le redimensionnement effectué.Warning: Cannot modify header information - headers already sent by (output started at E:\Serveur Web\www\strapontins\admin\mesfonctions.php:127) in E:\Serveur Web\www\strapontins\admin\mesfonctions.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at E:\Serveur Web\www\strapontins\admin\mesfonctions.php:127) in E:\Serveur Web\www\strapontins\admin\ajouter_photo_parcours_image.php on line 20
Comment je peux faire pour que tout fonctionne ? Bien sur, si je peux respecter la validation W3C ça serait d'autant mieux
Merci à vous de m'avoir lu
Cordialement
Ero
Partager