php - 无法将 base64 图像从颤振传递到 PHP
问题描述
PHP 代码
<?php
$image = $_POST['image'];
$name = $_POST['name'];
$decoded = base64_decode($image);
print_r($name);
print_r($decoded);
file_put_contents('myPath.', $decoded);
?>
出于某种原因,我通过 POST 方法传递的所有数据都是正确的,除了 base64 数据。它始终为空。
颤振代码
List<int> imageBytes = imageFile.readAsBytesSync();
String baseimage = base64Encode(imageBytes);
String fileName = "PHP_Sucks.jpg";
await http.post(
Uri.parse("https://www.xbyte.in/Console/Image.php"),
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: {
'image': baseimage,
'name': time,
}
).then((res) {
print(res.statusCode);
print(res.body);
}).catchError((err) {
print(err);
});
图片转base64没有错误。我可以在调用 API 之前打印它,它不是 Null,但不知何故我无法在服务器上接收它。我正在尝试其他事情,我尝试通过 baseimage.substring(0, 5000000) 并且它有效。我显然没有得到图像,但是数据可以打印在服务器上,当我将其增加到 baseimage.substring(0, 10000000) 时,它又变回了 null。是因为服务器上的某种限制吗?我以前从未遇到过这样的问题。有人可以帮我吗?
服务器详情 AWS EC2,Amazon Linux AMI 2,服务器版本:Apache/2.4.48 () 服务器构建:2021 年 6 月 25 日 18:53:37
解决方案
推荐阅读
- excel - Excel - 如何从两个单独的查找和值之间查找输出
- android - Android - Kotlin - 如何克服按钮的最小宽度限制?
- python - 构建简单神经网络时的 Python 代码
- ios - 如何在 Swift 中将数组值作为单独的参数传递?
- r - 用 tidyverse 找到最大值
- r - 将所有观察结果的 Shapley 原因代码附加到整个数据
- pentaho - PDI /Kettle - 将数据从前一跳传递到数据库查询
- python-3.x - 为什么 set_index 之后值会发生变化?
- python - 为什么两个相同的字符串在比较时返回的结果不一样?
- jobs - 如何在凌晨 02:00 后停止或终止工作