Upload file script not running once file is selected
<p><strong>Note</strong> I am not a PHP programmer. BUT I have made sure to scour the internet, the code in question, and all files and functions that relate to this code for obvious mistakes before posting this. Please Help.</p>

<p>I have an old project management system I am trying to recover for a client and the file uploading script has me stumped. The system allows my client to add projects that they are awarded (also project info, additional users, images, files, ect), so each project client can see updates from their individual log in pages. </p>

<p>The file upload form requires: a file description input(type="text"), and a file to be uploaded(type="text"). The systems other functions (project creation, adding project info, user creation, ect.) are all set up almost identically - file upload the exception -  and run perfectly. </p>

<p><strong>THE ISSUE</strong>: when a file is selected for upload the script seems to not execute at all. It will not even echo an error that the Description is empty. I tested the inputs:</p>

<pre><code>Test:

Descr. Empty;  File Empty  --   Error for Both.
Descr. Full;   File Empty  --   Error for File.
Descr. Empty;  File Full   --   No Error Window.
Descr. Full;   File Full   --   No Error Window.
</code></pre>

<p>I've tried a lot of different stuff to try and get this to work. Here is the original code I am working with, maybe someone can point out where the problem lies.</p>

<pre><code>&lt;?PHP 
    include("Security.php");

    //'==============================================================='
    //'JAM 11/05/03 Authenticate the user and ensure that they are an '
    //'             administrator.  If they are not a valid user and  '
    //'             administrator then redirect them to the logon     '
    //'             page.  Note that a Redirect URL is passed to the  '
    //'             routine.  The Redirect URL is used to send the    '
    //'             user to the originally target page if they logon  '
    //'             successfully.                                     '
    funAuthenticateAdministrator("FileDepot_Add.php");  
    //'==============================================================='
?&gt;  

&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!--
    function javCancel()
    {   
        //'======================================'
        //'JAM 11/05/03 Return to the file depot. '
        var objForm = document.forms[0];

        document.location.href = "TaskMenu.php";
        //'======================================'
    }   

    function javSave()
    {   
        var blnUserResponse = false;
        var strMessage = "";
        var objForm = document.forms[0];
        var objFirstEmptyField = null;

        //'====================================================='
        //'CER 09/16/04  Trim all the leading &amp; trailing spaces. '
        objForm.fileDesc.value = javTrim(objForm.fileDesc.value);
        objForm.fileuploaded.value = javTrim(objForm.fileuploaded.value);
        //'====================================================='

        //'==========================================================='
        //'CER 09/16/04 Replace all double quotes with single quotes. '
        objForm.fileDesc.value = javReplaceDoubleQuotes(objForm.fileDesc.value);
        objForm.fileuploaded.value = javReplaceDoubleQuotes(objForm.fileuploaded.value);
        //'==========================================================='

        //'======================================================='
        //'CER 9/15/04 Validate that the required fields have    '
        //'             been entered.  Also set a reference to    '
        //'             the first field that is missing - it will '
        //'             be used to set the focus to the field.    ' 
        if (objForm.fileDesc.value == "") 
        {
            strMessage += "File Description\n";

            if (objFirstEmptyField == null)
                objFirstEmptyField = objForm.fileDesc;
        }

        if (objForm.fileuploaded.value == "") 
        {
            strMessage += "File\n";

            if (objFirstEmptyField == null)
                objFirstEmptyField = objForm.fileuploaded;
        }
        //'======================================================='

        if (strMessage != "")
        {
            //'========================================================'
            //'CER 9/15/04 Prompt user with a list of missing fields. '
            //'             Then set the focus to the first incomplete '
            //'             field.                                     '
            window.alert("The following required fields are incomplete.\n\n" + strMessage);

            objFirstEmptyField.focus();
            //'========================================================'
        }
        if (strMessage = "")
        {
            //'======================================================='
            //'JAM 10/30/03 Prompt the user, asking them if they are  '
            //'             sure that they want to save the project   '
            //'             record.                                   '
            blnUserResponse = window.confirm("Are you sure you want to SAVE this project record?");

            if (blnUserResponse == true)
            {
                document.Form1.action = "FileDepot_Add_Save.php";
                document.Form1.submit();
            }
            //'======================================================='
        }                       
    }
--&gt;
&lt;/SCRIPT&gt;   

&lt;HTML&gt;
    &lt;HEAD&gt;
        &lt;TITLE&gt;Miller Information Systems - File Depot&lt;/TITLE&gt;

        &lt;?PHP 
            include("CustomStyleSheets.inc");
            include("GeneralJavaScripts.inc");
            include("GeneralFunctions.php");
            include("DatabaseFunctions.php");
        ?&gt;
    &lt;/HEAD&gt;
    &lt;BODY&gt;
        &lt;FORM NAME="Form1" METHOD=POST ACTION="" enctype="multipart/form-data"&gt;              
            &lt;?PHP
                $HeaderBGColor = "#3A6BCC";
                $HeaderForeColor = "White";
                $LeftColumnBGColor = "#EDEEF1";
                $LeftColumnForeColor = "#3A6BCC";
                $RightColumnBGColor = "#FFFFCC";
                $RowHeight = 28;
                $LeftColumnWidth = 200;
                $RightColumnWidth = 250;

                funDisplayPageHeader("Project File Depot - Add");

                echo "&lt;TABLE align=Center cellspacing=0 cellpadding=2&gt;";

                //'================'
                //'**** HEADER ****'
                //'================'

                echo "&lt;TR&gt;";
                echo    "&lt;TD align=center valign=center colspan=2 height=25 bgcolor=$HeaderBGColor&gt;";
                echo       "&lt;FONT face='Arial' size=2 color=$HeaderForeColor&gt;";
                echo          "&lt;B&gt;Add new file to an active project&lt;/B&gt;";
                echo       "&lt;/FONT&gt;";

                echo       "&amp;nbsp;";
                echo    "&lt;/TD&gt;";
                echo "&lt;/TR&gt;";

                //'=================='
                //'**** PROJECTS ****'
                //'=================='

                //'========================================================='
                //'CER 9/15/04 Create a SQL that returns all of the fields '
                //'             associated with ACTIVE Projects only. '
                $SQL = "SELECT projects.ID as ProjectsTableID,
                                projects.Name as ProjectName,
                                customers.ID,
                                customers.Name as CustomerName
                        FROM customers, projects
                        WHERE projects.Active = 1 AND projects.CustomerID = customers.ID 
                        ORDER BY customers.Name ASC, projects.Name";
                //'========================================================='

                //'==============================================='
                //'CER 9/15/04 Open the database connection and  '
                //'             retrieve the corresponding record '
                //'             set.  Then determine how many     '
                //'             records were returned.            '
                $LinkID = funOpenConnection();

                $ProjectRecordSet = mysql_query($SQL, $LinkID);

                $ProjectRecordCount = mysql_num_rows($ProjectRecordSet);
                //'==============================================='

                echo "&lt;TR&gt;";
                echo    "&lt;TD align=right width=$LeftColumnWidth height=$RowHeight bgcolor=$LeftColumnBGColor&gt;";
                echo       "&lt;FONT face='Arial' size=2 color=$LeftColumnForeColor&gt;";
                echo          "Customer &gt; Project:";
                echo       "&lt;/FONT&gt;";
                echo    "&lt;/TD&gt;";

                echo    "&lt;TD width=$RightColumnWidth height=$RowHeight bgcolor=$RightColumnBGColor&gt;";
                             //'======================================================'
                              //'CER 9/15/04 Loop throught the RecordSet and create a '
                              //'             corresponding item in the combo box for  '
                              //'             each project.                           '
                              echo "&lt;SELECT ID=ProjID NAME=ProjID SIZE=1 STYLE='WIDTH: 250px'&gt;";

                              for ($i = 0; $i &lt; $ProjectRecordCount; $i++)
                              {
                                $Row = mysql_fetch_array($ProjectRecordSet);

                                 echo "&lt;OPTION VALUE='" . $Row["ProjectsTableID"] . "'&gt;".$Row["CustomerName"] . " &gt; " . $Row["ProjectName"] . "&lt;/OPTION&gt;";
                              }

                              echo "&lt;/SELECT&gt;";
                              //'======================================================'
                echo    "&lt;/TD&gt;";
                echo "&lt;/TR&gt;";

                //'============================='
                //'**** File Description ****'
                //'============================='

                echo "&lt;TR&gt;";
                echo    "&lt;TD align=right width=$LeftColumnWidth height=$RowHeight bgcolor=$LeftColumnBGColor&gt;";
                echo       "&lt;FONT face='Arial' size=2 color=$LeftColumnForeColor&gt;";
                echo          "File Description:";
                echo       "&lt;/FONT&gt;";
                echo    "&lt;/TD&gt;";

                echo    "&lt;TD width=$RightColumnWidth height=$RowHeight bgcolor=$RightColumnBGColor&gt;";
                echo    "&lt;input type=\"text\" name=\"fileDesc\"  maxlength=\"50\"&gt;";
                echo    "&lt;/TD&gt;";
                echo "&lt;/TR&gt;";

                //'============================='
                //'**** File Name ****'
                //'============================='

                echo "&lt;TR&gt;";
                echo    "&lt;TD align=right width=$LeftColumnWidth height=$RowHeight bgcolor=$LeftColumnBGColor&gt;";
                echo       "&lt;FONT face='Arial' size=2 color=$LeftColumnForeColor&gt;";
                echo          "File:";
                echo       "&lt;/FONT&gt;";
                echo    "&lt;/TD&gt;";

                echo    "&lt;TD width=$RightColumnWidth height=$RowHeight bgcolor=$RightColumnBGColor&gt;";
                //'Include hidden fields for file upload variables'
                echo "&lt;INPUT TYPE=\"HIDDEN\" Name=\"MAX_FILE_SIZE\" value=\"10000000\"&gt;";
                echo "&lt;INPUT TYPE=\"HIDDEN\" Name=\"POST_MAX_SIZE\" value=\"10000000\"&gt;";
                echo "&lt;INPUT TYPE=\"HIDDEN\" Name=\"UPLOAD_MAX_FILESIZE\" value=\"10000000\"&gt;";
                echo    "&lt;input type=\"text\" name=\"fileuploaded\" maxlength=\"50\"&gt;";
                echo    "&lt;/TD&gt;";
                echo "&lt;/TR&gt;";

                echo "&lt;/TABLE&gt;";
                //'======================================================='
            ?&gt;

            &lt;TABLE align=center border=0&gt; 
                &lt;TR&gt;
                    &lt;TD align=center colspan=2&gt;
                        &lt;BR&gt;
                        &lt;INPUT type=Button VALUE='Cancel' OnClick='javascript:javCancel();'&gt;
                        &amp;nbsp
                        &lt;INPUT type=Button VALUE='Add' OnClick='javascript:javSave();'&gt;
                    &lt;/TD&gt;
                &lt;/TR&gt;
            &lt;/TABLE&gt;
        &lt;/FORM&gt;

        &lt;?PHP
            //'================================================================'
            //'JAM 11/05/03 Display the footer menu at the bottom of the page. '
            include("FooterMenu.php");      
            //'================================================================'
        ?&gt;
    &lt;/BODY&gt;
&lt;/HTML&gt;
</code></pre>
