formdata

Uploading Excel File in MVC using angularjs. HttpPostedFileBase is empty

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to upload an excel file in mvc using angular js. Following is my view code: <div class="browsebtn" ng-controller = "serviceablectrlr"><input type="file" id="dataFile" name="uploadFile" data-max-size="2097152" accept=".xls, .xlsx" onclick="$('#fileError').hide();" /> </div> <input id="btnUploadExcel" type="button" value="Upload" ng-click="UploadConfirmation()" class="btn btn-yellow" /> Following is my controller Code : var app = angular.module('ProductCatalog'); app.controller('serviceablectrlr', function ($scope, $http) { var

Image upload using AFMultipartFormData AFNetworking 3.0

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: NSURL *URL = [NSURL URLWithString:@"some APi"]; AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; UIImage *myImageObj = [UIImage imageNamed:@"avatar.jpg"]; NSData *imageData= UIImagePNGRepresentation(myImageObj); [manager POST:URL.absoluteString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFileData:imageData name:@"file" fileName:@"avatar.jpg" mimeType:@"image/jpeg"]; // etc. } progress:nil success:^

HTTP 400 Bad Request : javax.ws.rs.BadRequestException

匿名 (未验证) 提交于 2019-12-03 09:05:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I create a RESTful web service and write a client to use it . but when I run it i take HTTP 400 Bad Request : javax.ws.rs.BadRequestException exeption . this is my client code : String webserviceURI = "http://localhost:8084/fsc-access"; ClientConfig clientConfig = new ClientConfig(); Client client = ClientBuilder.newClient(clientConfig); URI serviceURI = UriBuilder.fromUri(webserviceURI).build(); WebTarget webTarget = client.target(serviceURI); MultivaluedMap formData = new MultivaluedMapImpl(); formData.add("plate", plate); formData.add(

FormData ajax upload on IE8 -&gt; alternatives and how it works

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm tyring to upload a picture with ajax, so I'm using FormData, but it's not working with IE8. I've looked about it and it's not possible to use FormData with IE8, but I've found nothing I've been able to use instead in order to make it work on IE8 and other browser. Could someone tell me what to do please, and how to do it ? The form I'm trying to submit <form id="addImgForm" name="addImgForm" method="post" action="#URL(Action('ChiliTest-ImageUpload'))#" enctype="multipart/form-data"> <input id="newImage" type="file" name="newImage">

Iterating through FormData in IE

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using FormData to send information back to the server. In some cases however I need to read out the data before I send it. Chrome allows you to iterate through the collection but IE does not supply the same methods. The code below works in Chrome: // Create a test FormData object var formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // Display the key/value pairs for(var pair of formData.entries()) { console.log(pair[0]+ ', '+ pair[1]); } JS Fiddle Does anyone know how to achieve the same

xhr.upload.onprogress doesn&#039;t work

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Everything in the following code will work, except it will never fire the xhr.upload.onprogress event. $(function(){ var xhr; $("#submit").click(function(){ var formData = new FormData(); formData.append("myFile", document.getElementById("myFileField").files[0]); xhr = new XMLHttpRequest(); xhr.open("POST", "./test.php", true); xhr.send(formData); xhr.onreadystatechange = function(){ if(xhr.readyState === 4 && xhr.status === 200){ console.log(xhr.responseText); } } xhr.upload.onprogress = function(e) { // it will never come inside here } });

Does IE10 support FormData()?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've read ( here ) that IE10 supports FormData(). But when I type this into the IE10 JavaScript console: foo = new FormData(); I get the error, "FormData not defined" Does IE10 support FormData() or doesn't it? Is there a trick to getting it to work in IE10? 回答1: I can confirm that it does - running your code in the console on this page works fine. I will therefore hypothesize that you are in Quirks Mode, and therefore the browser is pretending it doesn't know it to be compatible with said Mode. Make sure your page has a valid <!DOCTYPE html

Laravel 5.5 ajax call 419 (unknown status)

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I do an ajax call but I keep getting this error: 419 (unknown status) No idea what is causing this I saw on other posts it has to do something with csrf token but I have no form so I dont know how to fix this. my call: $('.company-selector li > a').click(function(e) { e.preventDefault(); var companyId = $(this).data("company-id"); $.ajax({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, url: '/fetch-company/' + companyId, dataType : 'json', type: 'POST', data: {}, contentType: false, processData: false, success

File Upload with Additonal Form Data to Web Api from MVC

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to upload a file with additional form data and post to Web API via MVC but i couldn't accomplish. MVC Side Firstly i got the submitted form at MVC. Here is the action for this. [ HttpPost ] public async Task < ActionResult > Edit ( BrandInfo entity ) { try { byte [] logoData = null ; if ( Request . Files . Count > 0 ) { HttpPostedFileBase logo = Request . Files [ 0 ]; logoData = new byte [ logo . ContentLength ]; logo . InputStream . Read ( logoData , 0 , logo . ContentLength ); entity . Logo = logo . FileName ; entity

Java REST Mailgun

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to take advantage of Mailgun's Transactional Email Service via their RESTful API, but I can not make it work. I am able to send emails via SMTP but i prefer to use their API. Their documentation provides me with the following code: public static ClientResponse SendSimpleMessage() { Client client = Client.create(); client.addFilter(new HTTPBasicAuthFilter("api", "key-*****")); WebResource webResource = client.resource("https://api.mailgun.net/v2/DOMAIN" + "/messages"); MultivaluedMapImpl formData = new MultivaluedMapImpl();