【问题标题】:$_FILES don't send name to MYSQL [duplicate]$_FILES 不将名称发送到 MYSQL [重复]
【发布时间】:2014-07-28 17:46:13
【问题描述】:

我用过论坛,用过这行:

<form method="post" action="adduser.php">
Picture:<input type="file" name="file" id="file" accept="image/gif, image/jpeg, image/png" /></br>

<input type="submit" name="submit">

也在 adduser.php 中

$image="pic/" .$_FILES["file"]["name"];

if(mysql_query("INSERT INTO users(userid,username,name,family,email,city,gender,password,img) values(' ','$_POST[username]','$_POST[name]','$_POST[family]','$_POST[email]','$_POST[city]','$_POST[gender]','$password','$image');",$cn))
echo "New user added";

怎么了?在我在 img 中看到的数据库表中:pic/

【问题讨论】:

  • 检查 $_FILES 是否不为空。并使用 filter_input 获取数据。

标签: php mysql file


【解决方案1】:

在表单中使用 enctype 属性

<form method="post" action="adduser.php" enctype="multipart/form-data">

【讨论】:

  • 我想更新它时也有问题。在edituser.php
猜你喜欢
  • 2017-04-10
  • 1970-01-01
  • 2014-07-13
  • 2012-07-04
  • 2016-02-22
  • 1970-01-01
  • 2015-11-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多