form-data

Creating a file from a blob

家住魔仙堡 提交于 2019-12-28 06:51:09
问题 I'm in need of some javascript guru. I have this code: handleImage(new File([blob], blob.name, {type: blob.type})).done(/* something */) and handleImage = function (image) { // create some fake form data var formData = new FormData(); formData.append("attachment", image); formData.append("auto", true); formData.append("_csrf", "xxxxxxxxx"); // post to the server. return $.ajax({ url: "/some/url", data: formData, cache: false, contentType: false, processData: false, type: 'POST', error:

FormData append item in array

喜欢而已 提交于 2019-12-28 06:44:23
问题 public List<Region> Regions { get; set; } in model called News.An Region Model is public class Region { public int Id { get; set; } public string Name { get; set; } public static Region Parse(DataRow row) { return new Region { Id = Database.GetInteger(row["Id"]), Name = Database.GetString(row["Region"]), }; } } in Javascript I am using AJAX post method with formdata. I want to set this region. var regionList = []; if (selected === "region") { if (region.length <= 0) { toastr.warning('Lütfen

Send FormData with other field in Angular

∥☆過路亽.° 提交于 2019-12-27 17:39:50
问题 I have a form with two input text and one upload . I have to send it to the server but I have some problem concatenating the file with the text. The server expects this answer: "title=first_input" "text=second_input" "file=my_file.pdf" This is the html : <input type="text" ng-model="title"> <input type="text" ng-model="text"> <input type="file" file-model="myFile"/> <button ng-click="send()"> This is the Controller : $scope.title = null; $scope.text = null; $scope.send = function(){ var file

Send FormData and String Data Together Through JQuery AJAX?

心已入冬 提交于 2019-12-27 11:40:07
问题 How can I post file and input string data with FormData() ? For instance, I have many other hidden input data that I need them to be sent to the server, html, <form action="image.php" method="post" enctype="multipart/form-data"> <input type="file" name="file[]" multiple="" /> <input type="hidden" name="page_id" value="<?php echo $page_id;?>"/> <input type="hidden" name="category_id" value="<?php echo $item_category->category_id;?>"/> <input type="hidden" name="method" value="upload"/> <input

Send FormData and String Data Together Through JQuery AJAX?

僤鯓⒐⒋嵵緔 提交于 2019-12-27 11:39:07
问题 How can I post file and input string data with FormData() ? For instance, I have many other hidden input data that I need them to be sent to the server, html, <form action="image.php" method="post" enctype="multipart/form-data"> <input type="file" name="file[]" multiple="" /> <input type="hidden" name="page_id" value="<?php echo $page_id;?>"/> <input type="hidden" name="category_id" value="<?php echo $item_category->category_id;?>"/> <input type="hidden" name="method" value="upload"/> <input

Convert json object to formData (HTML5 Object)

妖精的绣舞 提交于 2019-12-25 14:45:36
问题 I have seen many posts about converting formData to JSON object, however, I have the exact opposite use case. I have a JSON object which I would like to convert to a formData object as this is required by my endpoint API. My code right now: formdata = new FormData(); var uploadJson = { "default_lang": "en", "words": [ { "desc": $scope.selectedWord, "enabled": true, "examples": $scope.examples } ] }; formdata.append('file', uploadJson); However, formdata is always empty even after appending

How do I append a file to FormData()?

浪尽此生 提交于 2019-12-25 06:33:45
问题 fd.append("upload", file) yields, ------WebKitFormBoundaryJnjpATRkxe2Duwwu Content-Disposition: form-data; name="userid" 8022171621665209152 ------WebKitFormBoundaryJnjpATRkxe2Duwwu Content-Disposition: form-data; name="upload"; filename="sample.csv" Content-Type: text/csv ------WebKitFormBoundaryJnjpATRkxe2Duwwu-- fd.append("upload", evt.target.result) yields, ------WebKitFormBoundaryITfVxS7FbNWfk3Ty Content-Disposition: form-data; name="userid" 8022171621665209152 -----

JavaScript: Formdata append null value - NumberFormatException

半腔热情 提交于 2019-12-24 23:44:50
问题 The following client code FormData formData = FormData(document.getElementById(formElemId)); formData.append('version', null); when received in Server Side via Spring MVC as below @RequestParam(value = 'version', required = false) Integer versionNumber throws the following exception Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null" 回答1: You can resolve this issue by adding

Error 404 (not found) in ajax call with file inside FormData

a 夏天 提交于 2019-12-24 19:24:56
问题 I'm trying to invoke a PHP script to upload a file via Ajax. var fd = new FormData(); fd.append('file', file); console.log(file); var xhr = $.ajax({ url: 'https://www.mywebsite.com/it/file/upload/', type: 'POST', dataType: 'json', data: fd, cache: false, contentType: false, processData: false, success: function(result, message, xhr) { console.log(result); } }); For the moment, the PHP script simply displays the received file data header('Content-Type: application/json'); echo json_encode($

Post file to Server asp.net using XMLHttp

耗尽温柔 提交于 2019-12-24 14:17:43
问题 I use an Macro enabled word file. I need to save the document on the server given an URL and an aspx page to post to using VBA code here is what i have done . 'sends multipart/form-data To the URL using WinHttprequest/XMLHTTP 'FormData - binary (VT_UI1 | VT_ARRAY) multipart form data Function WinHTTPPostRequest(URL, FormData, Boundary) 'Dim http As New MSXML2.XMLHTTP 'Create XMLHTTP/ServerXMLHTTP/WinHttprequest object 'You can use any of these three objects. 'Set http = CreateObject("WinHttp