IMG dir 不能存储在 db 中,而是从查询中使用的相同变量中查看
我正在尝试使用Sanwebe的以下表单将图像上传到我的服务器。可以在这里找到。但是,当我按上传时,新的拇指加载完全正常。但是,我的图像无法使用与查看图像完全相同的变量上传到数据库。怎么会这样?我尝试将信息放在查询的前面。喜欢这个:db
echo '<div align="center">';
echo '<img src="images/profile-pictures/'.$thumb_prefix . $new_file_name.'" alt="Thumbnail">';
echo '</div>';
$profile_pic_temp = "../images/profile-pictures/" . $thumb_prefix . $new_file_name;
$profile_pic_full_temp = "../images/profile-pictures/" . $new_file_name;
$session_user = $_SESSION['user_confirm'];
require 'database.php';
$profile_pic_db_upload = $db->prepare("UPDATE login SET profile_picture_temp = :profile_pic_temp, profile_picture_full_temp = :profile_pic_full_temp WHERE user_session = :session_user");
$profile_pic_db_upload->bindParam(':session_user', $session_user, PDO::PARAM_STR);
$profile_pic_db_upload->bindParam(':profile_pic_temp', $profile_picture_temp, PDO::PARAM_STR);
$profile_pic_db_upload->bindParam(':profile_pic_full_temp', $profile_picture_full_temp, PDO::PARAM_STR);
$profile_pic_db_upload->execute();
$confirm_upload_db = $profile_pic_db_upload->rowCount();
if($confirm_upload_db != 0){
$popup_message = "Profile picture has been uploaded.";
echo $popup_message;
}
else{
$popup_message = "Profile picture could not be uploaded.";
echo $popup_message;
}
编辑二:查询现在运行,但是,我收到反馈“无法上传个人资料图片”。为什么查询无法正常运行?
编辑四:我已尝试将 更改为。然后我上传成功,但是,该值仅插入并设置为0。绑定参数以某种方式更改了值。为什么?user_session = :session_user
id = 1
profile_picture_temp
编辑三:我现在已经尝试过使用。同样的结果在这里。无法上载返回。但是, 不会更改 DB 中的值。mysqli
$sql = "UPDATE login SET profile_picture_temp = ? AND profile_picture_full_temp = ? WHERE user_session = ?";
$stmt = $mysqli->prepare($sql) or die ("Database error<br>" . $sql . "<br><b>Error message:</b> " . $mysqli->error);
$stmt->bind_param("sss", $profile_picture_temp, $profile_picture_full_temp, $session_user);
$stmt->execute() or die("Something went wrong");
if($stmt->fetch()){
$popup_message = "Profile picture has been uploaded.";
echo $popup_message;
}
else{
$popup_message = "Profile picture could not be uploaded.";
echo $popup_message;
}
$stmt->free_result();
$stmt->close();