Php “文件上传返回”;未定义索引“;错误
我正在尝试获取上载文件的错误,但出现以下错误:Php “文件上传返回”;未定义索引“;错误,php,file-upload,Php,File Upload,我正在尝试获取上载文件的错误,但出现以下错误: if(isset($_FILES['fichier']) && $_FILES['fichier']['error'] == 0) { //do stuff here, no problem } //get an error on this line "Notice: Undefined index: fichier in .." elseif($_FILES['fichier']['error'] !=
if(isset($_FILES['fichier']) && $_FILES['fichier']['error'] == 0)
{
//do stuff here, no problem
}
//get an error on this line "Notice: Undefined index: fichier in .."
elseif($_FILES['fichier']['error'] != 0)
{
}
else
{
echo 'no file selected or an error occured with the page.';
}
我需要获取错误代码(1到8)您的布尔逻辑不正确,导致在没有文件时调用
elseif
块。请尝试以下操作:
if (isset($_FILES['fichier'])) {
// we know we have a file; do our error checking.
if ($_FILES['fichier']['error'] == 0) {
// do stuff here, no problem
} else {
// handle the error
}
} else {
echo 'no file selected or an error occured with the page.';
}
检查是否在表单发送器中使用enctype='multipart/form data'发送文件