当我发送请求时,警报为空。文件上传很好,只是没有responsetext。我在这里做错了吗?
var request = new XMLHttpRequest();
request.open('POST','upload.php');
request.setRequestHeader('Cache-Control','no-cache');
request.send(data);
alert(request.responseText);
和upload.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";}
答案 0 :(得分:0)
您已处理$x
的输出,其值为1和2.如果未设置$x
,该怎么办?