我似乎无法将所有这些变量发布到我的数据库中。当我省略$_POST
. $file_desc
所有$_FILE
变量都传递到我的数据库。这是获取变量的代码:
$file_name = $_FILES['image']['name'];
$tmp = explode('.', $file_name);
$file_ext = strtolower(end($tmp));
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_error = $_FILES['image']['error'];
$file_desc = nl2br($_POST['desc']);
这是运行查询的代码:
$query = $pdo->prepare('INSERT INTO upload (name, type, size, desc) VALUES (?, ?, ?, ?)');
$query->bindValue(1, $file_name);
$query->bindValue(2, $file_ext);
$query->bindValue(3, $file_size);
$query->bindValue(4, $file_desc);
$query->execute();