gpt4 book ai didi

javascript - 将 dataURI 图像从 JavaScript 解析为 PHP

转载 作者:行者123 更新时间:2023-11-29 07:38:11 28 4
gpt4 key购买 nike

我在 JavaScript 中创建了一个函数,将用户选择的“图像”文件转换为 dataURI。然后我通过 POST 方法将其传递给 php 脚本。问题是当我尝试将这些信息保存到 MySQL 中时,如下所示

$him = $_POST["him"];
$req = $pdo->prepare("INSERT INTO `cr`.`chercheur`
(`cin`, `nom`, `prenom`, `statut`,
`tel1`, `email`, `tof`, `etat`)
VALUES (?, ?, ?, ?, ?,?, ?, '0')");
$req->execute(array($cin,$nom,$prenom,$statu,$tel,$mail,$him));

我在下面收到一个错误。

Warning: PDOStatement::execute(): MySQL server has gone away in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\CR\module\compte\demande\dem_user.php on line 89

Warning: PDOStatement::execute(): Error reading result set's header in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\CR\module\compte\demande\dem_user.php on line 89 SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

最佳答案

这可能是由于您尝试存储的图像大小足以溢出为 MySQL 配置的最大数据包大小。尝试将 MySQL 安装文件夹(在 [mysqld] 部分下)的 my.ini 中的 max_allowed_pa​​cket 设置更改为更大的值。

您可以使用以下 SQL 命令检查当前值(以及您设置的新值是否已生效):

SHOW VARIABLES LIKE 'max_allowed_packet';

查看此页面:http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

You can also get these errors if you send a query to the server that is incorrect or too large. If mysqld receives a packet that is too large or out of order, it assumes that something has gone wrong with the client and closes the connection. If you need big queries (for example, if you are working with big BLOB columns), you can increase the query limit by setting the server's max_allowed_packet variable, which has a default value of 1MB. You may also need to increase the maximum packet size on the client end. More information on setting the packet size is given in Section B.5.2.10, “Packet Too Large”.

关于javascript - 将 dataURI 图像从 JavaScript 解析为 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30005799/

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