开发者

Unable to upload doc and docx files

Here i am trying to upl开发者_JAVA技巧oad pdf, doc and docx files. Pdf files are uploading well but doc and docx files are not uploading. I kept enctype="multipart/form-data" property in form tag. What's the wrong with my code.

if ((($_FILES["uploadjob"]["type"] == "application/pdf") 
    || ($_FILES["uploadjob"]["type"] == "application/doc") 
    || ($_FILES["uploadjob"]["type"] == "application/docx"))) {
    if ($_FILES["uploadjob"]["error"] > 0) {
        echo "Return Code: ".$_FILES["uploadjob"]["error"]."<br />";
    } else {
        move_uploaded_file($_FILES["uploadjob"]["tmp_name"], "jobuploads/".$_FILES["uploadjob"]["name"]);
        // echo $_FILES["file"]["tmp_name"];
        $filename = $_FILES["uploadjob"]["name"];
    }
} else {
    echo "<br><br><br><center><font size='3' color='red'>Invalid file. Please upload only pdf, doc or docx files.</font><br><br> This page will be redirected after 5 seconds, Please wait................</center>";
    echo "<meta HTTP-EQUIV='REFRESH' content='5; url=jobopening.php'>";
    exit;
}


Check the Mime type of the document you are uploading, the rest of your code looks correct. You can check this with $_FILES[]["type"]. If the Mime type is different, add it to your IF condition and see if it works then.

If it still doesn't work, check that the filesize is under the limit set in PHP.ini. You can find filesize limits with phpinfo();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜