0
나는 Reactjs 애플 리케이션을 쓰고 ASP.Net 코어 2.0 백엔드 API 프로젝트에 따라 파일과 문자열을 게시하고있다. 백 엔드에 파일과 문자열 값을 게시하고 싶었습니다. 그러나 항상 오류를 보여줍니다. 내 ASP.Net 핵심 프로젝트에서 ASP.Net Core 2.0의 게시물 요청에서 파일 및 문자열 데이터를 수락하는 방법은 무엇입니까?
f.append("File",filesArray[i][0]);
f.append("member_code", this.state.member_code);
axios.post(apiBaseUrl
, f, {
headers: {'Content-Type': 'multipart/form-data'}
})
.then((response) => {
var result = response.data;
if(result[0].status == "1")
{
this.state.filesNames.push(result[0].filename);
if((i +1) == filesArray.length){
window.HideModal();
this.setState({filesPreview: null, filesToBeSent: null});
this.props.onClick(this.state.filesNames);
}
}
});
나는 다음과 같이 시도 :
[HttpPost]
[Route("upload")]
public async Task<IActionResult> Upload(FileUploadViewModel[] model)
{
var file = model.File;
var member_code = "test";
if (file.Length > 0)
{
string path = Path.Combine(_env.WebRootPath, "uploadFiles/member_files/" + member_code);
bool exists = System.IO.Directory.Exists(path);
if (!exists)
System.IO.Directory.CreateDirectory(path);
using (var fs = new FileStream(Path.Combine(path, file.FileName), FileMode.Create))
{
await file.CopyToAsync(fs);
}
}
return clsCommonFunctions.ConstructFileUploadResponse(clsConfig.status_success, file.FileName);
}
그러나 ASP.Net의 핵심 기능에
, 내가 다중/형태로 전달 모두 파일 및 문자열 값을 받아 들일 수 없다 -데이터.누구나 파일 및 ASP.Net 핵심 프로젝트에서 FormData로 문자열 값을 받아 들일 수 있습니다.
감사합니다.