i want send raw plain text in ajax call without additional header stuff like:
------webkitformboundarycwwjjby5xtdrlr48 content-disposition: form-data; name="upload"; filename="any" content-type: ....
ajax call:
var fd = new formdata(); fd.append( 'file', input.files[0] ); $.ajax({ url: '/handle_restful_call', data: fd, processdata: false, contenttype: false, type: 'post', success: function(data){ alert(data); } });
update: not using php on server side. topic possible send raw data??
xhr 2 supports file uploads. don't think can jquery, can native xmlhttprequest
.
var file = input.files[0]; var xhr = new xmlhttprequest; xhr.open('post', '/handle_restful_call'); xhr.setrequestheader('x-requested-with', 'xmlhttprequest'); xhr.setrequestheader('x-file-name', file.name); xhr.setrequestheader('content-type', file.type||'application/octet-stream'); xhr.onreadystatechange = function(){ if(xhr.readystate === 4 && xhr.status === 200){ var response = xhr.responsetext; } }; xhr.send(file);
Comments
Post a Comment