How to send an image to an api in dart/flutter?

The simplest method would be to post a multipart request like in this post and then post it to the server. Make sure to import these in the beginning of the file: import ‘package:path/path.dart’; import ‘package:async/async.dart’; import ‘dart:io’; import ‘package:http/http.dart’ as http; import ‘dart:convert’; Add this class somewhere in your code: upload(File imageFile) async { … Read more

Uploading multiple files asynchronously by blueimp jquery-fileupload

Solved. Fiddle: http://jsfiddle.net/BAQtG/29/ And js code $(document).ready(function(){ var filesList = [], paramNames = [], elem = $(“form”); file_upload = elem.fileupload({ formData:{extra:1}, autoUpload: false, fileInput: $(“input:file”), }).on(“fileuploadadd”, function(e, data){ filesList.push(data.files[0]); paramNames.push(e.delegatedEvent.target.name); }); $(“button”).click(function(e){ e.preventDefault(); file_upload.fileupload(‘send’, {files:filesList, paramName: paramNames}); }) })

FormData created from an existing form seems empty when I log it [duplicate]

Update: the XHR spec now includes several more functions to inspect FormData objects. FireFox has supported the newer functions since v39.0, Chrome is slated to get support in v50. Not sure about other browsers. var form = document.querySelector(‘form’); var formData = new FormData(form); for (var [key, value] of formData.entries()) { console.log(key, value); } //or console.log(…formData)

Retrofit 2 with only form-data

Here’s another Solution using request body: RequestBody requestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart(“param1”, param1) .addFormDataPart(“param2”, param2) .build(); apiInterface.somePostMethod(requestBody).enqueue( //onResponse onFailure methods ); here’s my api inteface POST method @POST(“somePostMethod”) Call<ResponseBody> somePostMethod(@Body RequestBody body); Hope it helps.

Node.js: How to send headers with form data using request module?

I’ve finally managed to do it. Answer in code snippet below: var querystring = require(‘querystring’); var request = require(‘request’); var form = { username: ‘usr’, password: ‘pwd’, opaque: ‘opaque’, logintype: ‘1’ }; var formData = querystring.stringify(form); var contentLength = formData.length; request({ headers: { ‘Content-Length’: contentLength, ‘Content-Type’: ‘application/x-www-form-urlencoded’ }, uri: ‘http://myUrl’, body: formData, method: ‘POST’ }, … Read more

Send FormData with other field in AngularJS

Don’t serialize FormData with POSTing to server. Do this: this.uploadFileToUrl = function(file, title, text, uploadUrl){ var payload = new FormData(); payload.append(“title”, title); payload.append(‘text’, text); payload.append(‘file’, file); return $http({ url: uploadUrl, method: ‘POST’, data: payload, //assign content-type as undefined, the browser //will assign the correct boundary for us headers: { ‘Content-Type’: undefined}, //prevents serializing payload. don’t … Read more

Webapi formdata upload (to DB) with extra parameters

Expanding on gooid’s answer, I encapsulated the FormData extraction into the provider because I was having issues with it being quoted. This just provided a better implementation in my opinion. public class MultipartFormDataMemoryStreamProvider : MultipartMemoryStreamProvider { private readonly Collection<bool> _isFormData = new Collection<bool>(); private readonly NameValueCollection _formData = new NameValueCollection(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, Stream> _fileStreams … Read more