django에서 ajax를 사용하여 백엔드에 파일과 메모를 저장하고 싶습니다. 파일에 문제가 생겼습니다. 파일을 백엔드로 보내는 방법. 참고 을 볼 수 있지만 볼 파일을 보낼 수 없습니다.django에서 ajax를 사용하여 파일을 데이터베이스에 저장하고 싶습니다.
<form class="horizontal-form" role="form" action="." method="post" enctype="multipart/form-data" id="nofilesforms">
<input type="file" name="image_file" id="image_file_data">
<textarea class="form-control notesdata" data-stylesheet-url="" name="notes"></textarea>
<button class="btn btn-primary" id="filesandnotes" type="button">Submit</button>
</form>
$(document).on('click','#filesandnotes',function(){
var notes = $('.notesdata').val();
var path = $('input[type=file][name=image_file]').val();
alert(path);
var data = {
notes:notes,
path:path
};
$.ajax({
url:"/cbs/msw1/",
type: "POST",
data: data,
success: function (response) {
},
error: function() {
}
});
});
누구든지 나를 안내 할 수 있습니다. 여기에 link입니다 감사는 파일 데이터 (파일 이름, 파일 크기, 방울 등) 얻을, 기본 제출 방지, 형태 자체가 아니라 click
이벤트의 submit
에 바인드 할 필요가 많은
"내가 백엔드에 무엇입니까"그 땅에 무엇을 의미 하는가 : 또한
, 당신이 jQuery를 파일 업로드 플러그인을 사용하실 수 있습니다? 또한 코드에서 이미 수행 한 진단에 대한 자세한 정보를 제공해야합니다. 그렇지 않으면, 이것은 "버그 사냥"질문입니다. – Louis