当我发送请求时,警报为空白。文件上传正常,只是没有响应文本。我在这里做错了吗?
var request = new XMLHttpRequest();
request.open('POST','upload.php');
request.setRequestHeader('Cache-Control','no-cache');
request.send(data);
alert(request.responseText);
并上传.php
if(!empty($_FILES['file'])){
foreach ($_FILES['file']['name'] as $key => $name) {
if($_FILES['file']['error'][$key] == 0 && move_uploaded_file($_FILES['file']['tmp_name'][$key],"video/$name"))
{
$x = "1";
}
else
{
$x = "2";
}
}
}
if ($x == "1"){echo "success";}
if ($x == "2"){echo "failed";}