Kirim data formulir dengan unggahan file menggunakan AJAX
// HTML
<form id="upload_form" enctype="multipart/form-data"></form>
// or specify exact data for FormData()
var formData = new FormData($('#upload_form')[0]);
formData.append('section', 'general');
formData.append('action', 'previewImg');
// Attach file
formData.append('image', $('input[type=file]')[0].files[0]);
//Sending form
//Ajax request with jquery will looks like this:
$.ajax({
url: 'Your url here',
data: formData,
type: 'POST',
contentType: false, // NEEDED, DON'T OMIT THIS (requires jQuery 1.6+)
processData: false, // NEEDED, DON'T OMIT THIS
// ... Other options like success and etc
});
Thoughtful Tapir