php - 如何修复此错误 Undefined offset: 1 in line 178
问题描述
数据库:
$data = $_POST["input1"];
$data = explode(",", $data)[1]; // line 178
$decoded_image = base64_decode($data);
$temp_name = 'img/'.md5(time().rand().time()).".png";
file_put_contents($temp_name, $decoded_image);
// Store this $file to table.
$file = basename($temp_name);
如何修复此错误
解决方案
$data 变量的 1 个索引,因此具有变量的右索引,就像这样
$data = explode(",", $data[1]);
推荐阅读
- javascript - document.write vs console.log vs innerHTML
- python-3.x - 为什么我在 Google colab 中得到“没有名为对象检测的模块”?
- python - 用烧瓶创建功能
- angular - Ionic 5 上的 LazyLoadImageModule
- python - 如何使用 python 从 NSE 图表中获取数据?
- vue.js - 渲染 Vuetify 日历时选择特定的月份或星期
- javascript - JavaScript 代码块有时会引发错误
- f# - 如何使用上下文对象在使用 F# GraphQL 的解析器之间共享数据?
- sql - 多行的 Postgres 声明类型
- amazon-athena - Amazon Athena 用例