0
클라이언트 측에서 Angular 또는 Javascript를 사용하여 파일을 만들어 서버로 보내려고합니다. MVC 내 서버 기능을 컨트롤러 사용 내 클라이언트 측에서, 내가 파일처럼 SavePivotFile에 보낼 객체가 지금클라이언트 측에서 파일 만들기 및 서버에 보내기
public void SavePivotFile(HttpPostedFileBase file)
{
try
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~"), System.Configuration.ConfigurationManager.AppSettings["reportsFolder"].ToString(), fileName);
file.SaveAs(path);
}
}
catch(Exception e)
{
throw;
}
}
입니다. 나는 이것을 시도했지만 나던 일을하지 않았다. 'options'객체는 JSON입니다.
$http({
method: 'GET',
url: '/FileManager/SavePivotFile',
params: {
file: options,
}
}).then(function successCallback(response) {
showNotification('The changes have been saved.', 'info');
}, function errorCallback(response) {
showNotification('Failed to save the file.', 'error');
});
또한 보내기 전에 새 FormData()를 만들려고했지만 작동하지 않습니다. 어떻게 고양이가 옵션 JSON 개체를 받아 파일과 같은 서버로 전달합니까?