Q:

restrictions on php file upload not working

I want to allow user to upload a file of txt ,doc or pdf format. I have written following code for it.
if ((($_FILES["uploaded"]["type"] == "text/plain")
        || ($_FILES["uploaded"]["type"] == "application/pdf")
        || ($_FILES["uploaded"]["type"] == "application/doc"))
        && ($_FILES["uploaded"]["size"] < 50000))
{
    if ($_FILES["uploaded"]["error"] > 0)
    {
        echo "Error: " . $_FILES["uploaded"]["error"] . "<br />";
    }
    else
    {
        $target = "upload/";
        $target = $target . basename($_FILES['uploaded']['name']);
        $ok = 1;
        if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
        {
            echo "The file " . basename($_FILES['uploadedfile']['name']) . " has been uploaded";
        }
        else
        {
            echo "Sorry, there was a problem uploading your file.";
        }
    }
}
else
{
    echo "Invalid file";
}

But this code is not working. Whatever be the case it always shows invalid file. What might be the problem?

A:

Problem was with MIME type. As said by @ksg91 correct MIME type for doc file is application/msword and for docx file it is: application/vnd.openxmlformats-officedocument.wordprocessingml.document 

