将Blob图片上传到我的数据库时出现问题

时间:2019-09-10 11:11:33

标签: php html mysql

所以我试图在我的数据库上上传个人资料图片。 这是我制作的一个小脚本。 我正在使用BLOB,但我尝试了很多事情,但是没有任何反应... 我可能不需要base64编码或解码吗?

有人可以花点时间看一下我的代码吗? 提前致谢。 :3

public WebDriverWait(
    IClock clock,
    IWebDriver driver,
    TimeSpan timeout,
    TimeSpan sleepInterval
)

Parameters
clock
    Type: OpenQA.Selenium.Support.UI.IClock
    An object implementing the IClock interface used to determine when time has passed.
driver
    Type: OpenQA.Selenium.IWebDriver
    The WebDriver instance used to wait.
timeout
    Type: System.TimeSpan
    The timeout value indicating how long to wait for the condition.
sleepInterval
    Type: System.TimeSpan
    A TimeSpan value indicating how often to check for the condition to be true.

1 个答案:

答案 0 :(得分:0)

不要在if statement内准备查询,请为if statement申请$stmt->execute()。 像这样修改您的代码

$password =password_hash($_POST['password'],PASSWORD_DEFAULT);
$file=file_get_contents(base64_decode($_FILES['profilepicture'['tmp_name']));
$stmt = $conn->prepare('INSERT INTO `users` (firstname, lastname, email, username, password, groupname, profilepicture) VALUES (?, ?, ?, ?, ?, ?, ?)');
$stmt->bind_param('ssssssb', $_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['username'], $password, $_POST['groupname'], $file);
if($stmt->execute()){
      echo 'You have successfully registered, you can now login!';
}else{
      echo 'Could not prepare statement!';
}
相关问题