php - 如何从 Ionic 接收 PHP 中的 $ FILES?
问题描述
我正在使用 FormData 将带有角度的 ionic 文件发送到 PHP,但是在 PHP 后端中,当您使 var dump $_FILES 显示为空时。
这是我在 .ts 中的代码:
file: File;
changeListener($event): void {
this.file = $event.target.files[0];
console.info(this.file); //First console info
const formData = new FormData();
const blobFile = new Blob([this.file], { type: this.file.type });
formData.append("file", blobFile, "filename");
this.myService.testing(formData).subscribe( resp => {
},(error)=>{
console.info(error);
})
}
在服务中:
testing(data) {
return this.http.post(url, body, {headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
}
PHP 支持:
$postdata = file_get_contents("php://input"); // this shows me the contents of the file
var_dump($_FILES); // returns an empty array
那么,我的错误是什么?我是从 Ionic 发送糟糕还是我在 PHP 中变得糟糕?
我正在使用codeigniter 3
谢谢 !
解决方案
推荐阅读
- php - 如何将 Angular 6 POST 值发送到 Codeigniter 函数?
- wordpress - 如何在 wordpress 中的 wp_list_table 中执行单个删除和批量删除操作?
- sql - 我们可以在 Oracle DB 11g 中更新表中的记录并同时将更新的记录插入到另一个表中吗
- jmeter - 使用 jmeter 的 odoo 性能(错误请求 CSRF 令牌)
- indexing - Neo4j 快速匹配模糊文本属性的方法
- webhooks - 如何将 rundeck 作业结果发布到 webhook
- android - 如何在工具栏中设置 MenuItem 文本而不是图标
- php - PHP网站数据库搜索-未显示mySQL查询结果
- python - 为什么这两个 fc api 行为不同?
- java - 使用 try-with-resources 语句可以完全防止异常屏蔽吗