2014-12-01 3 views
1

요청의 첫 번째 부분이 양식 데이터이고 두 번째 부분이 파일 인 다중 파트 양식이 있습니다. 요청의 첫 번째 부분에는 파일 이름이 누락되어 있고 두 번째 부분에는 이진 내용이 표시되어야하는 빈 페이로드가 있습니다.게시물의 빈 파일 요청 페이로드 및 양식 데이터의 빈 파일

A sample payload is as follows: 
------WebKitFormBoundaryiCmJmbQ7e518oDt9 
Content-Disposition: form-data; name="message" 

{"category":"OTHER","subject":"Test","body":"testttt"} 
------WebKitFormBoundaryiCmJmbQ7e518oDt9 
Content-Disposition: form-data; name="test.pdf"; filename="test.pdf" 
Content-Type: application/pdf 


------WebKitFormBoundaryiCmJmbQ7e518oDt9-- 

첫 번째 content-disposition에는 filename = "message"가 누락되어 있습니다. 이것을 Blob로 변경하려고 시도했지만 페이로드가 비어 있습니다. 내가 뭘하려고해도 파일을 페이로드에 표시 할 수 없습니다. 그것은 PDF 뭔가를 보여 주어야한다

내 아약스 요청 :

var data = new FormData(); 
data.append('message', JSON.stringify(message.attributes)); 
data.append(document.getElementById('fileInput').files[0].name,document.getElementById('fileInput').files[0]); 
message.save({},{ 
    cache: false, 
    contentType: false, 
    processData: false, 
    data: data 
}); 

답변

0

시도 :

message.save(null,{ 
    cache: false, 
    contentType: false, 
    processData: false, 
    data: data 
}); 

또한 here 백본 파일 업로드에 대한 질문입니다. 및 another 솔루션입니다.