我正在尝试上传文件但无法上传。它显示了flg值2.有人可以描述这个问题。
$file = $_FILES['file'];
$file_name = $file['name'];
$file_size = $file['size'];
$file_error = $file['error'];
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
$file_tmp = $file['tmp_name'];
$file_destination = 'upload/' . $title .'.' . $file_ext;
if($file_size < 2097152){
if(move_uploaded_file($file_tmp, $file_destination)){
$flg = 1;
}
else
{
$flg = 2;
}
}
else
{
$flg = 3;
}
答案 0 :(得分:0)
您应该使用document_root来获取这样的绝对路径:
$file_destination = $_SERVER['DOCUMENT_ROOT'] . "/upload/" . basename($_FILES['image']['name']);
move_uploaded_file($_FILES["image"]["tmp_name"], $file_destination);