form-data

FormData in IE8/9

雨燕双飞 提交于 2019-11-26 08:25:53
问题 i have implemented this script for uploading files with ajax, it works perfect in other browsers except for explorer, i noticed that formData is not supported by IE9 and less, are there any alternatives for formData in IE, and i want use clean javascript function doObjUploadExplorer(url, lnk_id, file, progress, success, content, frm, div_dlg, start_func){ var file_input = null, frm_data = new FormData(), req; try { //firefox, chrome, safari etc req = new XMLHttpRequest(); } catch (e) { //

Webapi formdata upload (to DB) with extra parameters

房东的猫 提交于 2019-11-26 08:03:41
问题 I need to upload file sending extra paramaters. I have found the following post in stackoverflow: Webapi ajax formdata upload with extra parameters It describes how to do this using MultipartFormDataStreamProvider and saving data to fileserver. I do not need to save file to server, but to DB instead. And I have already working code using MultipartMemoryStreamProvider, but it doesn\'t use extra parameter. Can you give me clues how to process extra paramaters in webapi? For example, if I add

appending array to FormData and send via AJAX

我只是一个虾纸丫 提交于 2019-11-26 07:25:47
问题 I\'m using ajax to submit a multipart form with array, text fields and files. I append each VAR to the main data as so var attachments = document.getElementById(\'files\'); var data= new FormData(); for (i=0; i< attachments.files.length; i++){ data.append(\'file\', attachments.files[i]); console.log(attachments.files[i]); data.append (\'headline\', headline); data.append (\'article\', article); data.append (\'arr\', arr); data.append (\'tag\', tag); then I use the ajax function to send it to

How to set File objects and length property at FileList object where the files are also reflected at FormData object?

狂风中的少年 提交于 2019-11-25 23:42:11
问题 It is possible to set .files property of <input type=\"file\"> element to a FileList from for example a different <input type=\"file\"> element .files property or DataTransfer.files property. See Make .files settable #2866, What happens between uploading a file to an HTML form and submitting it?. FileList object has a Symbol.iterator property which we can use to set a File object which is iterable, however the .files .length is still set to 0 and passing a <form> having <input type=\"file\">

How to inspect FormData?

旧城冷巷雨未停 提交于 2019-11-25 23:14:23
问题 I\'ve tried console.log and looping through it using for in . Here it the MDN Reference on FormData. Both attempts are in this fiddle. var fd = new FormData(), key; // poulate with dummy data fd.append(\"key1\", \"alskdjflasj\"); fd.append(\"key2\", \"alskdjflasj\"); // does not do anything useful console.log(fd); // does not do anything useful for(key in fd) { console.log(key); } How can I inspect form data to see what keys have been set. 回答1: Updated Method: As of March 2016, recent

Sending multipart/formdata with jQuery.ajax

断了今生、忘了曾经 提交于 2019-11-25 21:35:45
问题 I\'ve got a problem sending a file to a serverside PHP-script using jQuery\'s ajax-function. It\'s possible to get the File-List with $(\'#fileinput\').attr(\'files\') but how is it possible to send this Data to the server? The resulting array ( $_POST ) on the serverside php-script is 0 ( NULL ) when using the file-input. I know it is possible (though I didn\'t find any jQuery solutions until now, only Prototye code (http://webreflection.blogspot.com/2009/03/safari-4-multiple-upload-with

How to append whole set of model to formdata and obtain it in MVC

感情迁移 提交于 2019-11-25 21:35:29
问题 How do I pass a whole set model object through formdata and convert it to model type in the controller? Below is what I\'ve tried! JavaScript part: model = { EventFromDate: fromDate, EventToDate: toDate, ImageUrl: imgUrl, HotNewsDesc: $(\"#txthtDescription\").val().trim(), }; formdata.append(\"model\",model); then pass it through AJAX, it will be a string, and if I check the value of Request.Form[\"model\"] the result will be same, that is it will be received as string and value will be \"