如何使用php.so将单个文件上传到数据库中的各个行(由html表中的复选框选中),以便将文件上传到mysql数据库中的选定用户行。
答案 0 :(得分:0)
嗯..不确定这是否是你需要的,但是:
$db = new MySQLi("host", "user", "pass", "db"); # DB connection.
$ids = implode(",", $_POST['ids']); # Rows IDs.
$file = $db->real_escape_string(file_get_contents($_FILES['file']['tmp_name'])); # Uploaded file contents, escaped.
# Please note that some further checks on POST data are strongly adviced.
$db->query("UPDATE `mytable` SET `file` = '{$file}' WHERE `id` IN ({$ids})"); # Query.
显然,这需要一个适当的POST
请求,以及一个正确设置列的MySQL表。