PHP代码更新单个文件在mysql的许多用户在同一时间


php code to update single file to many users in mysql at a time

如何将单个文件上载到使用php的数据库中的各种行(由html表中的复选框选择)。

文件将被上传到mysql数据库中选定的用户行。

嗯…不确定这是否是您需要的,但是:

$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表。