Image upload werkt offline wel, online niet
Ik ben bezig met een site waarbij in het CMS een image upload functie zit. Deze werkte tot een paar weken geleden goed, maar opeens nu niet meer. Wat nog raarder is, is dat precies dezelfde code offline wel goed werkt, maar online niet.
Ik heb zelf al van alles geprobeerd, maar hij lijkt heel het script niet uit te voeren online.. kan dat liggen aan de server waarop de site staat?
Mijn code:
Code (php)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
include ('include/connection.php');
session_start();
error_reporting(E_ALL);
$id = $_SESSION['id']; //zelfde als personeelsnummer
$ingelogdnaam = $_SESSION['ingelogdnaam']; //zelfde als naam
if (!$_SESSION['login_oke'])
{
header("Location: index.php");
exit;
}
if (isset($_GET['uitloggen']))
{
session_destroy();
//$_SESSION['login_oke'] = FALSE;
header("Location: index.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Innplate CMS - Apparatuur toevoegen</title>
<!-- informatie voor zoekmachines -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Multivalent: plating, etching and more" />
<meta name="keywords" content="multivalent, plating, etching, reel-to-reel, conversion, anodizing, pickling" />
<meta name="author" content="Femke van Gemert" />
<!-- roep de stylesheet aan -->
<link rel="stylesheet" type="text/css" href="mystyle.css" media="screen" />
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /TinyMCE -->
</head>
<body>
<!-- header -->
<div id="header">
</div>
<div id="contentcontainer">
<!-- menu -->
<div id="menu">
<?php include("include/menu.php"); ?>
</div>
<!-- begin content div -->
<div id="content">
<h1>Nieuw apparatuur toevoegen</h1>
<form action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
<table border="0">
<tr>
<td>
<label for="titel">Titel:</label>
</td>
<td>
<input name="titel" type="text" value="<?php echo $titeltekst; ?>" />
</td>
</tr>
<tr>
<td>
<label for="inhoud">Tekst:</label>
</td>
<td>
<textarea name="inhoud" rows="10" cols="85"><?php echo $inhoudtekst; ?></textarea>
</td>
</tr>
<tr>
<td>
<label for="foto">Foto</label>
</td>
<td>
<p>Mag leeg gelaten worden!</p>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="file" name="foto">
</td>
</tr>
<tr>
<td>
<label for="zoekindex">Zoekindex:</label>
</td>
<td>
<select id="zoekindex" name="zoekindex">
<option value="1">Mag wel gevonden worden door een zoekopdracht</option>
<option value="0">Mag niet gevonden worden door een zoekopdracht</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="taal">Taal:</label>
</td>
<td>
<select id="taal" name="taal">
<option value="nederlands">Nederlands</option>
<option value="engels">Engels</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" name="toevoegen" value="Toevoegen" />
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['toevoegen']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
if(!empty($_POST['titel']))
{
$titelpost=$_POST['titel'];
$inhoudpost=$_POST['inhoud'];
$zoekindexpost=$_POST['zoekindex'];
$categoriepost="apparatuur";
$taalpost=$_POST['taal'];
$datumtoegevoegd=date("Y-m-d H:i:s");
$path = "images/fotoapparatuur/";
if (is_uploaded_file($HTTP_POST_FILES['foto']['tmp_name']))
{
if (($HTTP_POST_FILES['foto']['type']=="image/gif") || ($HTTP_POST_FILES['foto']['type']=="image/pjpeg") || ($HTTP_POST_FILES['foto']['type']=="image/bmp") || ($HTTP_POST_FILES['foto']['type']=="image/jpeg") || ($HTTP_POST_FILES['foto']['type']=="image/png"))
{
$res = copy($HTTP_POST_FILES['foto']['tmp_name'],$path.$HTTP_POST_FILES['foto']['name']);
if (!$res)
{
$aFout[] = "Het uploaden van de foto ging fout";
}
else
{
$fotopost = "images/fotoapparatuur/" .$HTTP_POST_FILES['foto']['name'];
}
}
else
{
$aFout[] = "U mag alleen afbeeldingen uploaden";
}
}
else
{
$fotopost = "geenfoto";
}
if(!empty($aFout))
{
$errors = '<ul class="fout">';
foreach($aFout as $sFout)
{
$errors .= "<li>".$sFout."</li>\n";
}
$errors .= '</ul>';
echo '<p>Het volgende ging mis:</p>';
echo $errors;
}
else
{
$toevoegen="INSERT INTO teksten (titel, inhoud, foto, datum, categorie, zoekindex, taal) VALUES ('$titelpost', '$inhoudpost', '$fotopost', '$datumtoegevoegd', '$categoriepost', '$zoekindexpost', '$taalpost')";
$resulttoevoegen = mysql_query($toevoegen);
if(!$resulttoevoegen)
{
echo "Er is iets misgegaan. Mysql error: " . mysql_error();
}
else
{
echo '<br />Apparatuur toegevoegd, je wordt nu door gelinkt naar het apparatuur overzicht.';
echo "<meta http-equiv='refresh' content='3; URL=apparatuurbeheer.php'>";
}
}
}
else
{
echo 'Je bent vergeten iets in te vullen!';
}
}
?>
<!-- einde content div -->
</div>
<!-- einde content container -->
</div>
<!-- even de floats clearen -->
<div style="clear:both;"></div>
<!-- footer -->
<div id="footer">
<?php include("include/footer.php"); ?>
</div>
</body>
</html>
</html>
include ('include/connection.php');
session_start();
error_reporting(E_ALL);
$id = $_SESSION['id']; //zelfde als personeelsnummer
$ingelogdnaam = $_SESSION['ingelogdnaam']; //zelfde als naam
if (!$_SESSION['login_oke'])
{
header("Location: index.php");
exit;
}
if (isset($_GET['uitloggen']))
{
session_destroy();
//$_SESSION['login_oke'] = FALSE;
header("Location: index.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Innplate CMS - Apparatuur toevoegen</title>
<!-- informatie voor zoekmachines -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Multivalent: plating, etching and more" />
<meta name="keywords" content="multivalent, plating, etching, reel-to-reel, conversion, anodizing, pickling" />
<meta name="author" content="Femke van Gemert" />
<!-- roep de stylesheet aan -->
<link rel="stylesheet" type="text/css" href="mystyle.css" media="screen" />
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /TinyMCE -->
</head>
<body>
<!-- header -->
<div id="header">
</div>
<div id="contentcontainer">
<!-- menu -->
<div id="menu">
<?php include("include/menu.php"); ?>
</div>
<!-- begin content div -->
<div id="content">
<h1>Nieuw apparatuur toevoegen</h1>
<form action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
<table border="0">
<tr>
<td>
<label for="titel">Titel:</label>
</td>
<td>
<input name="titel" type="text" value="<?php echo $titeltekst; ?>" />
</td>
</tr>
<tr>
<td>
<label for="inhoud">Tekst:</label>
</td>
<td>
<textarea name="inhoud" rows="10" cols="85"><?php echo $inhoudtekst; ?></textarea>
</td>
</tr>
<tr>
<td>
<label for="foto">Foto</label>
</td>
<td>
<p>Mag leeg gelaten worden!</p>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="file" name="foto">
</td>
</tr>
<tr>
<td>
<label for="zoekindex">Zoekindex:</label>
</td>
<td>
<select id="zoekindex" name="zoekindex">
<option value="1">Mag wel gevonden worden door een zoekopdracht</option>
<option value="0">Mag niet gevonden worden door een zoekopdracht</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="taal">Taal:</label>
</td>
<td>
<select id="taal" name="taal">
<option value="nederlands">Nederlands</option>
<option value="engels">Engels</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" name="toevoegen" value="Toevoegen" />
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['toevoegen']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
{
if(!empty($_POST['titel']))
{
$titelpost=$_POST['titel'];
$inhoudpost=$_POST['inhoud'];
$zoekindexpost=$_POST['zoekindex'];
$categoriepost="apparatuur";
$taalpost=$_POST['taal'];
$datumtoegevoegd=date("Y-m-d H:i:s");
$path = "images/fotoapparatuur/";
if (is_uploaded_file($HTTP_POST_FILES['foto']['tmp_name']))
{
if (($HTTP_POST_FILES['foto']['type']=="image/gif") || ($HTTP_POST_FILES['foto']['type']=="image/pjpeg") || ($HTTP_POST_FILES['foto']['type']=="image/bmp") || ($HTTP_POST_FILES['foto']['type']=="image/jpeg") || ($HTTP_POST_FILES['foto']['type']=="image/png"))
{
$res = copy($HTTP_POST_FILES['foto']['tmp_name'],$path.$HTTP_POST_FILES['foto']['name']);
if (!$res)
{
$aFout[] = "Het uploaden van de foto ging fout";
}
else
{
$fotopost = "images/fotoapparatuur/" .$HTTP_POST_FILES['foto']['name'];
}
}
else
{
$aFout[] = "U mag alleen afbeeldingen uploaden";
}
}
else
{
$fotopost = "geenfoto";
}
if(!empty($aFout))
{
$errors = '<ul class="fout">';
foreach($aFout as $sFout)
{
$errors .= "<li>".$sFout."</li>\n";
}
$errors .= '</ul>';
echo '<p>Het volgende ging mis:</p>';
echo $errors;
}
else
{
$toevoegen="INSERT INTO teksten (titel, inhoud, foto, datum, categorie, zoekindex, taal) VALUES ('$titelpost', '$inhoudpost', '$fotopost', '$datumtoegevoegd', '$categoriepost', '$zoekindexpost', '$taalpost')";
$resulttoevoegen = mysql_query($toevoegen);
if(!$resulttoevoegen)
{
echo "Er is iets misgegaan. Mysql error: " . mysql_error();
}
else
{
echo '<br />Apparatuur toegevoegd, je wordt nu door gelinkt naar het apparatuur overzicht.';
echo "<meta http-equiv='refresh' content='3; URL=apparatuurbeheer.php'>";
}
}
}
else
{
echo 'Je bent vergeten iets in te vullen!';
}
}
?>
<!-- einde content div -->
</div>
<!-- einde content container -->
</div>
<!-- even de floats clearen -->
<div style="clear:both;"></div>
<!-- footer -->
<div id="footer">
<?php include("include/footer.php"); ?>
</div>
</body>
</html>
</html>
Ik hoop dat iemand mij verder kan helpen!
Gewijzigd op 15/07/2010 20:19:31 door Femke van Gemert
Script is gevoelig voor SQL-Injection.
En ja dat weet ik, dat moet ik nog veilig maken, dat moet eigenlijk eerst, maar ik wilde eerst een upload functie werkend hebben :)
is de juiste map gechmod?
$HTTP_POST_FILES['..'] is verouderd en word uitgefaseerd.
"
Heb je localhost een verouderde versie van php. of heb je in php.ini aanstaan dat $HTTP_POST_FILES mogelijk is?
Ik gok zo maar wat, maar ik denk dat het probleem daar ligt.
Maar dan weet ik dat voortaan! Bedankt voor de hulp & uitleg.