Click to See Complete Forum and Search --> : Form validation with file upload


tripwater
12-04-2004, 12:32 PM
Hello,

I know how to validate a normal form but I am incorporating a file upload with this as well because I need to gather additional info.


It is not working as of now, here is my code:




<SCRIPT LANGUAGE=\"JavaScript\">



function TheFormCheck()
{
if (document.file.project.value == \"\" || document.userfile.project.value == \"\")
{
alert(\"Please select a file to upload to continue.\");
document.file.userfile.focus();

return false;
}


</script>

<body>

<form name=\"file\" method=\"post\" enctype=\"multipart/form-data\" action=\"../admin/media_uploadsubmit.php\" onSubmit=\"return TheFormCheck()\">

<table width=600 align=center border=0>
<tr>
<td colspan=2>
<b>Attach(upload) a file to the project you select in the drop list below.</b>
</td>
</tr>
<tr>
<td>
<b><span style=color:blue>*</span></b> Project
</td>
<td>
<select name=project>
<option value=\"\"> ----------";


$query = "select ProjectID, ProjectName from project order by ProjectName";

$result = @mysql_query($query);

for ($i = 0; $i < @mysql_num_rows($result); $i++)
{
$row = @mysql_fetch_array($result);

$value .= "<option value = \"".$row["ProjectID"]."\">".$row["ProjectName"];

}


$value .= "</select>
</td>

</tr>
<tr>
<td>
<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"60000000\">
Upload this file :
</td>
<td>
<INPUT TYPE=\"file\" name=\"userfile\">
<INPUT TYPE=\"submit\" name=\"load\" value=\"Upload\"><br><br>
</td>
</tr>
<tr>
<td colspan=2>
<input type=radio name=media value=1> Image
<input type=radio name=media value=2 checked> Video
</td>
</tr>
</table>
</form>
</body>





Thank you for your time