Bonjour,

Voila j'ai un problème pour uploader une image et ceci juste sous internet explorer

Si je le fais sous firefox pas de soucis, je comprend pas pourquoi je vous met mon code


test.php

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
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
 
<body>
 
  <form action="test2.php" name="formulairecreer" method="post" enctype="multipart/form-data" >
 
  <input type="hidden" name="MAX_FILE_SIZE" value="2097100" />
 
  <input type="file" name="fichier"  > <br /> 
 
 
	<br />
 
	<input  name="submit" type="submit" value="Valider l'annonce"  />
</body>
</html>
test2.php

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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
 
<body>
<?
function getextension($file) {
return strtolower(array_pop(explode('.', $file)));
}
 
 
$upload="upload/";
$preview ="miniatures/";
$images="images/";
 
 
 
function create_thumbs($d,$file, $w, $h) {
global $upload;
 
 
 
//source de l'image
$sfile = $upload  . $file;
//destination de l'image
$dfile = $d . $file;
 
echo"dfile:$dfile<br>";
echo"sfile:$sfile<br>";
 
 
switch (getextension($sfile)) {
case 'jpg':
case 'jpeg':
$simg = imagecreatefromjpeg($sfile);
break;
case 'png':
$simg = imagecreatefrompng($sfile);
break;
case 'gif':
$simg = imagecreatefromgif($sfile);
break;
}
//retourne la largeur de l'image 
$currwidth = imagesx($simg);
//retourne la hauteur de l'image 
$currheight = imagesy($simg);
 
 
if ($currheight > $currwidth ) {//1141*688
$zoom = $h / $currheight;//create_thumbs($preview, $nom_fichier, 58, 45);
$newheight = $h;
$newwidth = $currwidth * $zoom;
$dimension=1;
} else {
$zoom = $w / $currwidth;
$newwidth = $w;
$newheight = $currheight * $zoom;
$dimension=0;
}
 
 
$dimg = @imagecreate($newwidth, $newheight) or die ("Image incorrecte");
 
 
imagetruecolortopalette($simg, true, 256);
$palsize = ImageColorsTotal($simg);
for ($i = 0; $i < $palsize; $i++) {
$colors = ImageColorsForIndex($simg, $i);
ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);
}
 
imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
switch (getextension($sfile)) {
case 'jpg':
case 'jpeg':
imagejpeg($dimg, $dfile);
break;
case 'png':
imagepng($dimg, $dfile);
break;
case 'gif':
imagegif($dimg, $dfile);
break;
}
 
ImageDestroy($simg);
ImageDestroy($dimg);
 
}
 
 
//type du fichier
	$type=$_FILES['fichier']['type'];
	$name=$_FILES['fichier']['name'];
 
	echo"type:$type<br>";
	echo"name:$name<br>";
 
	//extension du fichier
	$extension=substr(strrchr($_FILES['fichier']['type'],'/'),1);
	echo"extension:$extension<br>";		
	//Taille maxi en octet (2mo)
	$maxsize=2097100;
	//Nom du fichier apres upload
	$nom_fichier = microtime().".".$extension;
 
	echo"nom_fichier:$nom_fichier<br>";
	//repertoire
	$repertoire="upload/";
 
	$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png','JPG' , 'JPEG' , 'GIF' , 'PNG' );
 
	//Vérification du fichier uploadé
 
	function upload($index,$destination,$maxsize=FALSE,$extensions=FALSE)
	{
		//Test1: fichier correctement uploadé
		if (!isset($_FILES[$index]) OR $_FILES[$index]['error'] > 0) return FALSE;
		//Test2: taille limite
		if ($maxsize !== FALSE AND $_FILES[$index]['size'] > $maxsize) return FALSE;
		//Test3: extension
		$extension_upload = substr(  strrchr($_FILES['fichier']['name'], '.')  ,1);
		if ($extensions !== FALSE AND !in_array($extension_upload,$extensions)) return FALSE;
		//Déplacement
		return move_uploaded_file($_FILES[$index]['tmp_name'],$destination);
	}
 
 
	$resultat = upload('fichier',$repertoire.$nom_fichier,$maxsize,$extensions_valides );
 
					if(!$resultat){
					exit("erreur upload");
					}
 
 
 
					else
					{
					echo"ok upload nom du fichier :$nom_fichier";
					}
 
//le nom de l'image a été inséré dans la base en même temps que l'upload
 
 
				$req=mysql_query("select Photo1 
					from table");
 
 
 
 
				$champ = mysql_fetch_array($req);
 
 
					$photo1=$champ['Photo1'];
 
 
 
 
 
 
 
								if($dimension==0)
								{
								create_thumbs($preview, $photo1, 58, 45);
								create_thumbs($images, $photo1, 450, 348);
								}
								else
								{
								create_thumbs($preview, $photo1, 37, 45);
								create_thumbs($images, $photo1, 287, 348);
								}
							  echo"<img src=\"$preview$photo1\">";
							  unlink("$upload$photo1");
 
 
?>
 
</body>
</html>

Vous pouvez tester vous verrez c'est vraiment étrange

Message d'erreur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
Warning: imagesx(): supplied argument is not a valid Image resource in /mnt/149/sdb/1/d/xxx/test2.php on line 48
 
Warning: imagesy(): supplied argument is not a valid Image resource in /mnt/149/sdb/1/d/xxx/test2.php on line 50
 
Warning: Division by zero in /mnt/149/sdb/1/d/xxx/test2.php on line 59
Image incorrecte

Merci de votre aide





Le fichier est bien uploadé par contre la création de la miniature pose problème



On m'a parler de mime mais je vois pas ou je dois intervenir pour changer cela

Merci