Код: Выделить всё
File
Submit
myForm = new FormGroup({
file: new FormControl('', [Validators.required]),
fileSource: new FormControl('', [Validators.required])
});
constructor(private http: HttpClient) { }
ngOnInit(): void {
}
get f(){
return this.myForm.controls;
}
onFileChange(event) {
if (event.target.files.length > 0) {
const file = event.target.files[0];
console.log('File', file);
this.myForm.get('fileSource').setValue(file);
}
}
submit(){
const formData = new FormData();
formData.append('file', this.myForm.get('fileSource').value);
this.http.post('http://localhost/]api/document/SaveContact.php', formData)
.subscribe(res => {
console.log(res);
// alert('Uploaded Successfully.');
})
}
}
Это базовая загрузка файла, которую я пытаюсь использовать с помощью angular и php.
Когда я выбираю файл в пользовательском интерфейсе, я вижу детали файла.
Но когда я его выполняю, я получаю пустой массив в качестве ответа на вкладке сети.
В чем может быть проблема?
Я проверил файл php.ini, и все кажется нормально я.
Подробнее здесь: https://stackoverflow.com/questions/798 ... load-issue
Мобильная версия