Ok, so this mess (below) is what I've got currently. It is supposed to do a lot of things that basically result in a very "simple" (for the user) file-uploader... it checks for duplicate files and adds an integer to the end -- which doesn't work... and it's supposed to create a directory if there isn't already one for that "plat" -- which also doesn't work...

PHP Code:
            // NEW FILE -- UPLOAD IT!
            
if ($_FILES["file"]["error"] > 0){
                echo 
"<li>Error: " $_FILES["file"]["error"] . "</li>";
            }
            else{
                echo 
"\n\n<li>File: " $_FILES["file"]["name"] . "</li>\n";
                echo 
"<li>Type: " $_FILES["file"]["type"] . "</li>\n";
                echo 
"<li>Size: " round(($_FILES["file"]["size"] / 1024),2) . " Kb</li>\n";
                echo 
"<li>Temporary File: " $_FILES["file"]["tmp_name"] . "</li>\n";
                
$uploadto = ('docs/plat/p'.$plat.'/');
                    
$thisFile $uploadto $_FILES["file"]["name"];
                    if (
file_exists($thisFile)){
                        
$duplicate_filename TRUE;
                        echo(
"<li>" $_FILES["file"]["name"] . " already exists.</li>");
                        
$filename_data explode("."$_FILES["file"]["name"]);
                    }else{
                        
$duplicate_filename FALSE;
                    }
                        
$newName $_FILES["file"]["name"];
                        for(
$i=0;$duplicate_filename;$i++){
                            
$new_filename $filename_data[0] . "_" $i "." $filename_data[1];
                            if(
file_exists($new_filename)){
                                
$duplicate_filename TRUE;    // Cycle Again
                            
}
                            else{
                                
$_FILES["file"]["name"] = $new_filename;
                                
$duplicate_filename FALSE;
                            }
                        }
                        if(!
is_dir($uploadto)){mkdir($uploadto);}else{} // Add a Docs Folder for this plat -- if it doesn't have one already
                        
move_uploaded_file($_FILES["file"]["tmp_name"],
                        
$uploadto $_FILES["file"]["name"]);
                        echo 
"<li>Stored in: " $uploadto $_FILES["file"]["name"] . "</li></ul>\n";
                        
$fileplat $platID;
                        
$filetitle $_REQUEST['title_new'];
                        
$filefile $_FILES["file"]["name"];
                        
$filecategory $_REQUEST['category_new'];
                        
$fileuser $_SESSION['id'];
                        
$filedate date('Y-m-d');
                        
$fileformat $_FILES["file"]["type"];
                        
$fileactive $_REQUEST['active_new'];
                        
$filequery "INSERT INTO addendaData VALUES (NULL, '$fileplat', '$filetitle', '$filefile', '$filecategory', '$fileuser', '$filedate', '$fileformat', '$fileactive')";
                        
$fileDB = new ConnectDB(); //instantiate a new Connect class
                        
$fileresult $fileDB->ExecuteQuery($filequery);
                        if(
$fileresult){
                            echo(
"\n<ul><li>The New Document (".$filetitle.": <a href=\"".$uploadto.$_FILES["file"]["name"]."\" style=\"color:#FFF;\" target=\"_blank\">".$_FILES["file"]["name"]."</a>) for <strong>\"$platName\"</strong> was added successfully.</li></ul>");
                        }
                        else{
                            echo(
"<li>Error while trying to add the new document for <strong>\"$platName\"</strong>! Please Contact the <a href=\"mailto:webmaster@newhometeam.net\">System Adminstrator</a> to report this error.</li></ul>");
                        }
                        
$DB->Close();