i just dont get it working 🙁 tried it on serveral ways... still not working.
Ik dont want to be rude, but.. take a look at my code.. can you (or anyone) see where to change it?.. tnhx a lot!
<?php
include '../library/config.php';
include '../library/opendb.php';
if (!isset($_GET['id'])) {
echo "Album id is not defined";
exit;
} else if(isset($_POST['upload'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$label = $_POST['label'];
if (!get_magic_quotes_gpc()) {
$name = addslashes($name);
$label = addslashes($label);
}
if ($_FILES['userfile']['tmp_name']) {
$name = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$uploadDir = '../image/';
$filePath = $uploadDir . $name;
if( file_exists($filePath) ) {
unlink($filePath);
}
$result = move_uploaded_file($tmpName, $filePath);
// $result = move_uploaded_file($tmpName, $_SERVER['DOCUMENT_ROOT'] . '/image/' . $_FILES['userfile']['name']);
if (!$result) {
echo "Error uploading file";
exit;
}
} else {
$name = "name"; //zit hier de fout?...
}
$query = "UPDATE upload ".
"SET label = '$label', name = '$name', path = '$filePath',size = '$fileSize', type = '$fileType' ".
"WHERE id = '{$_GET['id']}'";
mysql_query($query) or die('Error, modify album failed : ' . mysql_error());
} else {
$id = $_GET['id'];
$sql = "SELECT id, name, label, path FROM upload WHERE id = '{$_GET['id']}'";
$result = mysql_query($sql) or die('Error, get album info failed. ' . mysql_error());
if (mysql_num_rows($result) == 0) {
} else {
$row = mysql_fetch_assoc($result);
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="400" border="0" cellpadding="8" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#990066">
<tr>
<td class="info">Titel:</td>
<td><input name="label" type="text" id="label" value="<?php echo $row['label']; ?>"> </td>
</tr>
<tr>
<td class="info">Locatie:</td>
<td><input name="path" type="text" id="path" value="<?php echo $row['path']; ?>"> </td>
</tr>
<tr>
<tr>
<td class="info">Huidge afbeelding: </td>
<td><?php echo '<img class=scale2 src="../image/' . $row['name'] . '" />' ; ?></td>
</tr>
<tr>
<td class="info">Afbeelding uploaden:</td>
<td><input name="userfile" type="File" class="box" id="userfile" size="15"></td>
</tr>
<tr>
<td class="info"> </td>
<td><input name="upload" type="Submit" id="upload" value="Uploaden">
<input type="hidden" name="id" value="<? echo "$id"; ?>" /></td>
</tr>
</table>
</form>
<?php
}
}
?>
<input name="btnCancel" type="button" id="btnCancel" value="Terug" onclick="window.history.back();" />