PHP Upload form, PDF, Doc & Docx

前端 未结 3 1411
萌比男神i
萌比男神i 2020-12-21 05:13

I\'m struggling to make this upload code work for a docx file, it works okay for doc and pdf..

$allowedExts = array(\"pdf\", \"doc\", \"docx\");
$extension =         


        
3条回答
  •  萌比男神i
    2020-12-21 05:54

    There is another way to do the task. Just check the file type and then you can work further.

    Here is code to check the filetype.

    $target_dir = "uploads/";
    $filename= $_FILES["fileupload"]["name"]; //gets filename with type
    $target_file = $target_dir . basename($filename); //uploads/file.type
    echo $target_file;
    $extension= pathinfo($target_file,PATHINFO_EXTENSION); 
    $imageFileType = strtolower($extension);
    if(strcmp($imageFileType,"docx")==0){
        echo "Its word file";
    }
    

提交回复
热议问题