个人资料图片不会上传到数据库中。它被上传到文件夹中,但在数据库中它只是说NULL。
代码:
if (Input::exists()) {
if (Token::check(Input::get('token'))) {
try {
$user->update(array(
'image' => $title
));
if (isset($_FILES["image"])) {
$title = date("dmyHms") . "_" . $_FILES["image"]["name"];
$path = "img/profile/" . $_POST["id"] . "_" . $title;
move_uploaded_file($_FILES["image"]["tmp_name"], $path);
}
} catch (Exception $e) {
die($e->getMessage());
}
}
}
表格:
这是解决方案,它将图像保存在数据库中:
$user->update(array(
'image' => 'image',
'image' => $title
));