ajax 로 Form Data 전송
var postData = new FormData();
$.each($('#editForm').serializeArray(),function(key,row){
postData.append(row.name,row.value);
});
var maxSize = 0;
$.each($("#attachImage")[0].files, function(i, file) {
console.log(file);
// maxSize += file.size;
postData.append('photo['+i+']', file);
});
if(maxSize > 0){
var maxSizeMb = maxSize / 1000 / 1000;
console.log(maxSizeMb);
if(maxSizeMb > 10){
alert('첨부 이미지는 한번에 10MB 까지 가능합니다.');
return false;
}
}
$("#btnSubmit").prop("disabled", true);
$.ajax({
url: "./uploadImage",
data: postData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
dataType:'json',
success: function(res) {
$("#btnSubmit").prop("disabled", true);
}
});
2 Comments
Jordan Singer
2d2 replies
Santiago Roberts
4d