Drummin Posted September 2, 2011 Share Posted September 2, 2011 I'm working on a portal project for a school and they make weekly flyers like the one attached below. Now if the file attaches to this post, then at least I know some script changes will fix the problem. The school has an archive of hundreds of these docs they'd like to load up, so I need a solution. I've made many versions of my upload script, which have been working fine for any word documents I create, but not for their word docs. This is the code in my latest version. <?php require("checkpass2.php"); require("../teacher/checkpass.php"); require("../access.inc.php"); mysql_connect("$host","$login","$pass") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); mysql_select_db("$db") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); include("../commonsettings.php"); IF ($_POST['upload']){ //$directory="$siteurl"; $directory=".."; $section=$_POST['section']; $directoryname = preg_replace('/[^a-zA-Z]/', '', $section); $directlevel="$directory/$directoryname"; if(!file_exists($directlevel, 0777)) { mkdir($directlevel); } $target_path = "$directlevel/"; $loaddate = date('MY'); $filename = preg_replace('/\s+/', '', $_FILES['uploadedfile']['name']); $file_basename = substr($filename, 0, strripos($filename, '.')); // strip extention $file_ext = substr($filename, strripos($filename, '.')); // strip name $filesize = $_FILES["uploadedfile"]["size"]; if (($file_ext == ".doc" || $file_ext == ".docx") && ($filesize < 200000)) { // rename file $newfilename = $file_basename."_Uploaded_".date('M-Y') . $file_ext; $nfilename = $newfilename; if (file_exists($target_path . $newfilename)) { unlink($target_path . $newfilename); mysql_query("DELETE FROM ".$conf['tbl']['uploads']." WHERE filename='$nfilename' AND section='$directoryname'") or die(mysql_error()); } if (!file_exists($target_path . $newfilename)) { move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $target_path . $newfilename); $result = mysql_query("INSERT INTO ".$conf['tbl']['uploads']." SET filename='$nfilename', section='$directoryname'") or die(mysql_error()); header("Location:UploadFiles.php"); } } elseif (empty($file_basename)) { // file type error header("Location:UploadFiles.php?error=1"); } else { // file selection error header("Location:UploadFiles.php?error=2"); } } ?> Any help greatly appreciated. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.