【发布时间】:2019-02-11 19:31:33
【问题描述】:
朋友们你好,我在 Angular 4 中创建了一个项目,我想上传图像并向 PHP 文件发送请求,但表单数据无法附加值和图像。 请帮我 我包括FormGroup、FormControl、FormBuilder、Validators、Http
const Image = this.com_Image.nativeElement;
if (Image.files && Image.files[0]) {
this.comImageFile = Image.files[0];
}
const ImageFile: File = this.comImageFile;
// [enter image description here][1]
let formData = new FormData();
formData.append('companyName', value.companyName);
formData.append('username', value.username);
formData.append('uploadFile', ImageFile, ImageFile.name);
console.log(formData);
【问题讨论】:
-
您是否可以选择将其作为 base64 字符串发送?
-
不,我在我的表单数据中找不到结果