No worries about posting times, we have a relaxed environment here.
To check the size of the file, you need to use a size checking function, such as filesize(), so it would look like this:
//We check the uploaded file's size, 200000 Bytes = 200KB
if (filesize($_FILES['uploaded']['tmp_name']) > 200000)
{
echo "Your file is too large.<br>";
$ok=0;
} This will directly check the temporary file of which they uploaded to.
You can also change your HTML form as well to check the file before it is uploaded:
<form enctype="multipart/form-data" action="careers.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="200000" />
<input type="submit" value="Upload" />
</form>
Next you need to check the MIME type to see if it is a doc format, this may be different depending on the format, so this may work:
//if MIME is not msword
if ($_FILES['uploaded']['type'] != "application/msword")
{
echo "File is not Microsoft Word document<br>";
$ok=0;
} And finally to see if the file already exists, we need to check if the target file exists:
//if location where it is going to exists, detect that.
if(file_exists($target)
{
echo "Please select a different name, file already exists.<br/>";
$ok = 0;
}I have not tested it, so feel free to integrate those changes and we can fix the problems as they come along!
~Alexander.