文件上传。判断。一维二维数组

$arr = [];

// 文件上傳接口PHP
if ($_FILES) {

  if ($_FILES['file']['type'] == 'image/pan' || $_FILES['file']['type'] == 'image/jpg' || $_FILES['file']['type'] == 'image/jpeg' || $_FILES['file']['type'] == 'image/gif' && $_FILES['file']['size'] < 1 * 1024 * 1024) {
    $ext = explode('.', $_FILES['file']['name']);
    $ext = end($ext);
    $thumb = "/upload/p".time().rand(1000,9999).'.'.$ext;
    move_uploaded_file($_FILES['file']['tmp_name'], '.' . $thumb);

    $arr['code'] = 1;
    $arr['msg'] = $thumb;
  } else {
    $arr['code'] = 2;
  }
} else {
  $arr['code'] = 3;
}
echo json_encode($arr);
// 判断是否登录
if(empty($_COOKIE['admin']) || !isset($_COOKIE['admin'])){
    header("location:login.php");
}
// <!-- 查询管理员 -->
$id = $_COOKIE['admin'];
$conn = new mysqli('localhost','root','root','qwer');
$sqe = "select * from wer where id = $id";
$res = $conn->query($sqe);
// 转换成一维数组
$info = $res->fetch_assoc();
// 转化成二维数组
// $liar = $res->fetch_all(MYSQLI_ASSOC);
原文地址:https://www.cnblogs.com/mark645524126/p/13590672.html