/    Sign up×
Community /Pin to ProfileBookmark

Form validation with file upload

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:

[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>

[/code]

Thank you for your time

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @tripwater spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...