Send and Upload file and data using ajax jquery

var files;
$('input[type=file]').on('change', prepareUpload);
function prepareUpload(event){
files =;
function sendChat(type){
var formData = new FormData();
var content=$("#content").val();
formData.append('meetup_id', meetup_id); formData.append('type', type); formData.append('content', content); $.each(files, function(key, value){ formData.append(key, value); alert(value); });
return false;
url: 'api/url.php',
type: 'POST',
dataType: 'json',
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
headers: {
"Authorization": AUTH_ADITYA,
"Accept": "application/json",
"cache-control": "no-cache",
beforeSend: function () {
complete: function (data) {
success: function (data) {

error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);

Leave a Reply