form-data

MVC Convert Base64 String to Image, but … System.FormatException

江枫思渺然 提交于 2019-12-06 01:19:00
问题 My controller is getting an uploaded image in the request object in this code: [HttpPost] public string Upload() { string fileName = Request.Form["FileName"]; string description = Request.Form["Description"]; string image = Request.Form["Image"]; return fileName; } The value of image (at least the beginning of it) looks a lot like this: data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEAYABgAAD/7gAOQWRvYmUAZAAAAAAB/... I tried to convert using the following: byte[] bImage = Convert.FromBase64String

HTML5 FormData file upload with RubyOnRails

笑着哭i 提交于 2019-12-05 22:25:40
问题 I using this script to upload file (one by one) with HTML5 FormData in Rails 3.2.8 application. http://jsfiddle.net/RamPr/ $('.uploader input:file').on('change', function() { $this = $(this); $('.alert').remove(); $.each($this[0].files, function(key, file) { $('.files').append('<li>' + file.name + '</li>'); data = new FormData(); data.append(file.name, file); $.ajax({ url: $('.uploader').attr('action'), contentType: 'multipart/form-data', type: 'POST', dataType: 'json', data: data,

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

♀尐吖头ヾ 提交于 2019-12-05 22:10:44
I saw other questions, but thats not what i want, i dont want to upload an image to a server, i dont want to convert to base64... I only want to post a file in a form data or something else and get the returned info. i have this, but has not work: void onTakePictureButtonPressed() { takePicture().then((String filePath) { if (mounted) { setState(() { imagePath = filePath; videoController?.dispose(); videoController = null; }); http.post('http://ip:8082/composer/predict', headers: { "Content-type": "multipart/form-data", }, body: { "image": filePath, }).then((response) { print("Response status:

Express body-parser req.body with formdata is empty object

﹥>﹥吖頭↗ 提交于 2019-12-05 15:01:21
Somehow my req.body is always empty, maybe you have an idea: here is my server code: const Express = require('express'); const bodyParser = require('body-parser'); const app = new Express(); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.post('/save', (req, res) => { console.log(req.body) // => {} res.send(req.body); }); const env = process.env.NODE_ENV || 'production'; app.listen(3000, err => { if (err) { return console.error(err); } console.info(`Server running on http://localhost:${port} [${env}]`); }); When I try to send formdata with javascript the req

Get All Items from HTML5 FormData Object - HTML5

徘徊边缘 提交于 2019-12-05 10:04:18
I have been working with the HTML5 FormData object and I can't seem to figure out how to find what data it holds. I need to access it for debugging purposes. https://developer.mozilla.org/en-US/docs/Web/API/FormData 1 There are functions like FormData::get([name]); but I don't know the names. It would be nice to have something like the following: FormData::dumpData(); What is a good way to view all of the data in a FormData object? Update Here is an example of the FormData object: All the functions for FormData aren't available in all browsers by default. However, you can enable them in some.

XMLHttpRequest & FormData not submitting data

℡╲_俬逩灬. 提交于 2019-12-05 09:29:35
I am trying to submit a form via ajax using the post method and a FormData object. Here is a simplified version of the JavaScript: var form=…; // form element var url=…; // action form['update'].onclick=function(event) { // button name="update" var xhr=new XMLHttpRequest(); xhr.open('post',url,true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var formData=new FormData(form); formData.append('update', true); // makes no difference xhr.send(formData); xhr.onload=function() { alert(this.response); }; }; The form has: a button ( type="button" name="update" ) to run

Express parsing multipart/form-data post in req.body

落花浮王杯 提交于 2019-12-05 07:14:36
问题 I'm trying to upload a file using jQuery Ajax + FormData object found on Chrome and Firefox browsers. The code I'm using to do it is the following: var formData = new FormData(); formData.append('image', $scope.image.data); $.ajax({ url: '/wines/'+id+'/image', type: 'POST', data: formData, processData:false, contentType:false }).done(function(){ $location.path('/'); }); By looking at the developer tools I can see that the request is formed correctly, however express is recognising the

How to append files in input type file with multiple before uploading [closed]

霸气de小男生 提交于 2019-12-05 04:36:15
I select 2 images and again I select 3 images second time before upload, the first two gets removed from input type file and last 3 images are still there. I know it's the default behavior of input type file, that it replaces the new files with new selected ones, but I want to keep all the files user selects multiple times before upload. How is it possible? I am using ajax and formdata. I have face same problem like you now i have found solution for that <input type="file" id="attachfile" name="replyFiles" multiple> <!--File Element for multiple intput--> <div id="#filelist"></div> <script>

javascript xhr file upload without jQuery

允我心安 提交于 2019-12-05 04:01:22
问题 i have some trouble to make xhr file upload without jquery. (please don't said that use jQuery). if the browser support FormData API and use it, i heard it is possible to upload file(s) also. the matter is i don't know how the attach file into FormData object. and second problem is how to send the FormData via XHR? i mean, look at the code below: var formData = new FormData(); formData.append('somevalue', 'somevalue'); // string formData.append( ???, ??? ); // file var xhr = new

How can my Servlet receive parameters from a multipart/form-data form?

£可爱£侵袭症+ 提交于 2019-12-05 02:51:56
问题 I have a page that has this piece of code: <form action="Servlet" enctype="multipart/form-data"> <input type="file" name="file"> <input type="text" name="text1"> <input type="text" name="text2"> </form> When I use request.getParameter("text1"); in my Servlet it shows null. How can I make my Servlet receive the parameters? 回答1: All the request parameters are embedded into the multipart data. You'll have to extract them using something like Commons File Upload: http://commons.apache.org