gpt4 book ai didi

php - 如何将通过 HTTP Post 接收到的图像保存到 mySQL 中

转载 作者:行者123 更新时间:2023-11-29 05:14:42 27 4
gpt4 key购买 nike

我想使用 PHP 将通过 http 接收的图像写入我的数据库。我使用

访问图像
$inputImage = file_get_contents('php://input');

回显 $inputImage 工作正常,因此到服务器的传输不会成为问题。

我现在尝试插入图像

$sqlRequest="INSERT INTO Image(time, data) SET (NOW(), '$inputImage')";
mysqli_query($connection, $sqlRequest) or die("Error in Inserting " . mysqli_error($connection));

但它不起作用,我收到以下错误

Error in Inserting You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET (NOW(), '����' at line 1

有人可以给我提示吗谢谢

编辑:好的,更改了语法问题,必须查找 blob 问题

最佳答案

使用 VALUES() 而不是 SET()SET 用于更新(使用 UPDATE),而 VALUES() 用于插入(使用 INSERT)。

参见 this INSERT 语法和 this用于 UPDATE 语法。

关于php - 如何将通过 HTTP Post 接收到的图像保存到 mySQL 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34679515/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com