I just can't understand this. I thought the problem had gone away earlier but it is back, though not all the time.
I've just uploaded the file about 8 times, having made small changes to the .doc document. Only 3 of those times was it uploaded properly. The rest, when I opened or downloaded it from the website it remained unchanged (ie the old version).
Here's the code which processes the updating of the file:
$plan_datefor = trim($plan_date . " " . $plan_month);
if (!empty($plan_datefor)) {
$plan_datefor = "Monday " . $plan_datefor;
$update1 = "UPDATE planning SET datefor = '$plan_datefor' WHERE id = $id";
$result1 = mysql_query($update1) or die(mysql_error());
}
if (!empty($plan_topic)) {
$update3 = "UPDATE planning SET topic = '$plan_topic' WHERE id = $id";
$result3 = mysql_query($update3) or die(mysql_error());
}
$error = 0;
$file_tempname = $_FILES['plan_upload']['name'];
$extension = strchr($file_tempname, '.');
if (!empty($file_tempname)) {
if (!empty($file_tempname) && $extension != ".jpg" && $extension != ".gif" && $extension != ".png" && $extension != ".doc"
&& $extension != ".xls" && $extension != ".txt" && $extension != ".notebook" && $extension != "xbk"
&& $extension != ".pdf" && $extension != ".ppt" && $extension != ".zip" && $extension != ".rar"
&& $extension != ".exe" && $extension != ".html" && $extension != ".swf" && $extension !=".txt") {
$error = 5;
$error_message = "The file you have chosen is of illegal file type. Please choose another.";
}
if ($error == 0) {
echo "error = 0";
$sql = "SELECT * FROM planning WHERE id = '$id'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
extract($row);
unlink($upload);
$filedir = "planning/";
$file_tempname = $filedir . $_FILES['plan_upload']['name'];
move_uploaded_file($_FILES['plan_upload']['tmp_name'], $file_tempname);
$fileid = $id;
$newfilename = $filedir . $fileid . $extension;
rename($file_tempname, $newfilename);
$update2 = "UPDATE planning SET upload = '$newfilename' WHERE id = $id";
$result2 = mysql_query($update2) or die(mysql_error());
$redirect = "planning.php";
header("Refresh: 1.5; URL=$redirect");
include "includes/header.inc.php";
echo "<p>Plan updated successfully.</p>";
echo "<p>Redirecting...</p>";
include "includes/footer.inc.php";
and the test statement echo "error = 0" is being shown.
__________________ Clive |