【发布时间】:2020-06-13 01:52:47
【问题描述】:
我有一个带有 Angular 前端和 PHP 后端的简单应用程序。我在前端上传一个文件,需要在后端处理它。 我的角度代码看起来像,
const formData = new FormData();
formData.append('file', this.selectedFile, 'transaction_file');
this.http.post('http://localhost/MyBackend/index.php', formData).subscribe(res => {
console.log(res);
alert('success!');
});
并且在我的后端项目的index.php 中,我尝试使用此文件访问此文件,
$postdata = file_get_contents("php://input");
但是这个 $postdata 似乎是空的。非常感谢任何如何在后端获取此文件的想法。
【问题讨论】:
标签: php angular file-upload