form-data

Can't append content to FormData()

江枫思渺然 提交于 2019-12-10 17:22:28
问题 I have two different JS functions to handle image uploads. One to read the file and to (globally) create the FormData object and the other to send it to a PHP file via AJAX. Even though the file is valid I can't append it to the FormData. And strings neither. And as it turns out I'm only sending empty XHRequests via Ajax, because I don't get any other content from PHP then empty arrays. Since the first JS function initializes the formData variable globally the second function should have no

FormData doesn't include value of buttons

心不动则不痛 提交于 2019-12-10 15:09:47
问题 Consider the following snippet: $('#myBtn').click(function(e) { e.preventDefault(); var formElement = $(this).closest('form')[0]; var request = new XMLHttpRequest(); request.open("POST", "https://posttestserver.com/post.php"); request.send(new FormData(formElement)); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form method="POST" action="https://posttestserver.com/post.php"> <input type="text" name="wtf" /> <button type="submit" name="lol"

Jquery: Push FormData?

两盒软妹~` 提交于 2019-12-10 14:39:46
问题 Is there a way to add additional data to a formdata element that handles a file upload? I know formdata doesn't support .push()? $("frm").submit(function (e) { e.preventDefault(); var data = new FormData($(this)[0]); }); 回答1: If I'm understanding your question correctly, you want to add extra keys and values to the FormData object after taking them from the form. If so, yes you can! It uses the append method: data.append('SomeField', 'SomeValue'); You can do this with a string, or with a Blob

How send application/x-www-form-urlencoded params to a RestServer with JMeter?

泄露秘密 提交于 2019-12-10 12:52:20
问题 I developed a rest server, and I put it to run in localhost, and I'm trying to perform tests with JMeter, sending requests posts and gets (depends of called method). I already send to Rest server and got result with JMeter in simple post requests, get requests, sending files with post, and sending a Json with post. But I don't know how to send a Form-UrlEncoded object to server. My Rest server consumes application/x-www-form-urlencoded , and I need to send 3 String parameters. There's some

Sending Audio Blob to server

旧城冷巷雨未停 提交于 2019-12-10 11:29:53
问题 I am trying to send an audio blob produced by WebAudio API and Recorder.js to my Laravel Controller using jQuery's $.post method. Here is what I am trying. $('#save_oralessay_question_btn').click(function(e){ var question_content = $('#question_text_area').val(); var test_id_fr = parseInt($('#test_id_fr').val()); var question_type = parseInt($('#question_type').val()); var rubric_id_fr = $('#rubric_id_fr').val(); var reader = new FileReader(); reader.onload = function(event){ var form_data =

'FormData' is undefined in IE only

↘锁芯ラ 提交于 2019-12-10 03:17:05
问题 I have a problem where i need to post the data as content-type application/x-www-form-urlencoded . var inputData = {cId:"444",pageNo:"1",latitude:"49.153236",longitude:"12.040905"}; var data = new FormData(); data.append('data', JSON.stringify(inputData)); this.model.save(data, { data: data, processData: false, cache: false, contentType: false, success: function (model, resultData) { $.get(App.baseUrl + 'templates/all-offers-view.html', function (data) { template = _.template(data, { data:

angular get image data and again append it to FormData

时光总嘲笑我的痴心妄想 提交于 2019-12-09 17:10:46
问题 In angular 5 I am getting the images for hotelgallery from mongodb through my service. So basically the data what I am getting is like this { fieldname: "hotelgallery", originalname: "e.jpg", encoding: "7bit", mimetype: "image/jpeg", destination: "./public/", encoding : "7bit", filename : "1521139307413.jpg" mimetype : "image/jpeg" path : "public/1521139307413.jpg" size : 66474 } { fieldname: "hotelgallery", originalname: "e.jpg", encoding: "7bit", mimetype: "image/jpeg", destination: ".

Using FORM DATA with Alamofire

这一生的挚爱 提交于 2019-12-09 15:39:57
问题 I am using alamofire for some time now, but I have never used a form data Post. Now I am stuck. I have 2 params (email, password) and don't know how POST them to server. Can anyone give me an example please? 回答1: And here is a sample code for Alamofire 4.0 in Swift 3.0 let url = "http://testurl.com" let parameters = [ "email": "asd@fgh.hjk", "password": "55555" ] Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.default).responseJSON { response in switch

Is it possible to set accept-charset for new FormData (XHR2) object or workaround

◇◆丶佛笑我妖孽 提交于 2019-12-08 17:09:49
问题 Here is example code (http://jsfiddle.net/epsSZ/1/): HTML: <form enctype="multipart/form-data" action="/echo/html" method="post" name="fileinfo" accept-charset="windows-1251"> <label>Label:</label> <input type="text" name="label" size="12" maxlength="32" value="får løbende" /><br /> <input type="submit" value="Send standart"> </form> <button onclick="sendForm()">Send ajax!</button> JS: window.sendForm = function() { var oOutput = document.getElementById("output"), oData = new FormData

API Gateway Encoding multipart/form-data

大城市里の小女人 提交于 2019-12-08 06:02:02
问题 I have a beanstalk reflected in my API gateway with passthrough, where my client sends a direct multipart/form-data request to beanstalk. The image sends correctly and I can open it normally, but when I make the request from the API Gateway, I can't open the image. Looks like the API Gateway encode messes up the image content when performing the passthrough to beanstalk. How I can set the Api Gateway encode or make a pure passthrough? 回答1: I'm Brazilian, so I talked to the Brazilian AWS team.