Insert BLOB
Issue #24
resolved
Hi, how to prepare statement with blob? Example in common MySQLi:
<form method="post" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*">
<button type="submit" name="submit">Submit</button>
</form>
$null = NULL;
$stmt = $mySQLi->prepare("INSERT INTO table (string1, string2, string3, image) VALUES (?, ?, ?, ?)");
$stmt->bind_param("sssb", $_POST['string1'], $_POST['string2'], $_POST['string3'], $null);
$stmt->send_long_data(3, file_get_contents($_FILES['image']['tmp_name'])); // Insert image from POST
$stmt->execute();
$stmt->close();
Comments (2)
-
-
reporter - changed status to resolved
- Log in to comment
Pawel,
I extended the class and added my own prepare method, which returns the underlying mysqli_stmt object to handle cases like this.
Which, per your example, I would call like this
The rest of your binds, executes, etc... should work normally on the stmt object (outside of this wrapper class).