为什么我的PHP函数向我显示空白页

时间:2018-11-21 07:53:02

标签: php html ajax

我正在尝试将文件上传到我的上载文件夹中,但是每当我单击提交时
告诉我空白页没有任何反应。 这是PHP下方的代码

<?php
$file_name=$_FILES['fileToUpload']['name'];
$targetdir='uploads/';
$target_file=$targetdir.basename($_FILES['fileToUpload']['name']);
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$file_tmp=$_FILES['fileToUpload']['tmp_name'];
$file_type=$_FILES['fileToUpload']['type'];
$uploadok=1;
$name=$_POST['yourname'];
  if (isset($_POST['submit'])) {
     $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
     if($file_type=="application/pdf"){
         move_uploaded_file($file_tmp,"uploads/".$file_name);
         echo "file uplaoded";
}
elseif($check!==false) {
       move_uploaded_file($file_tmp,"uploads/".$file_name);
        echo "file is an image";
        echo "File will be show by your name".$name;
        $uploadok=1;
     }
else{
    echo "file type is wrong";
}
}


?>

这是我的ajax代码

function take() {
            xmlhttp= new XMLHttpRequest();
            xmlhttp.onreadystatechange=callback:
            xmlhttp.open("GET","uploads.php",true);
            xmlhttp.send();
        }
        function callback() {
            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById('display').innerHTML=xmlhttp.responseText;
        }
        }

0 个答案:

没有答案