formdata

JS:How to send multiple files using FormData(jQuery Ajax)

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my form multiple file uploads are there,using FormData only one file is uploading ,though I'm selecting more than one file to upload,following is the code HTML JS var ajaxData = new FormData(); ajaxData.append( 'action','uploadImages'); jQuery.each($("input[name^='photo']")[0].files, function(i, file) { ajaxData.append('photo['+i+']', file); }); $.ajax({ url: URL, data: ajaxData, cache: false, contentType: false, processData: false, type: 'POST', dataType:'json', success: function(data) { if (data.status == 'success') { location.reload();

Ajax FileUpload & JQuery formData in ASP.NET MVC

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some problem with posting formData to server side action method. Because ajax call doesn't send files to server, I have to add file uploader data to formData manually like this: var formData = new FormData(); formData.append("imageFile", $("#imageFile").file); formData.append("coverFile", $("#coverFile").file); I wrote jQuery function that need to post form data to server using ajax call. It's works but posted formData in server side is always null! this is my script: Edit 1: This is the action method in controller: public

How to upload file in Angular2

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have to submit a form along with image. i have tried this code (with multiple ways) but did't work for me. is there anyone having working demo of file uploading using angular2 please help me out. component.html Name * Image Upload component.ts myfile={ "name":"Mubashshir", "image":'' } fileChangeEvent(fileInput: any){ this.myfile.image = fileInput.target.files; } upload(){ this.base_path_service.PostRequest('http://128.199.190.109/api/school/schoolDetail/',this.myfile) .subscribe( data => { console.log("data submitted"); }, err => console

Post formdata via XMLHttpRequest object in JS ? ( cross browser)

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im trying to post a form data in js : I have this code : var formData = new FormData(); formData.append("username", "Groucho"); formData.append("accountnum", 123456); formData.append("afile", "2"); var xhr = new XMLHttpRequest(); xhr.open("POST", "http://xxxxx/xx.ashx",true); xhr.send(formData); Formdata according MDN is not available in IE ( or unknown). When I try this in FF : ( i think its fine...). when I try in IE : What is the solution to post form data ( or my data but in objective way) CROSSBROWSER ? 回答1: You didn't say which version

Post modelcontaining HttpPostedFileBase file along with some parameters using form.serialize() in mvc4

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a ViewModel containing some string and HttpPostedFileBase properties . When i am posting the model to the controller using below ajax call, $ . ajax ({ url : '@Url.Action("_AddFeedback", "Mcq")' , type : 'post' , data : $ ( 'form#frm-feedback' ). serialize (), // data: formData, success : function ( data ) { alert ( "done" ); }, error : function ( data ) { alert ( "Error occured while saving Option's data." ); } }); I am getting value for string but null for HttpPostedFileBase type properties. How can we post

How do you POST a FormData object in Angular 2?

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to upload a file and send some json along with it, I have this function: POST_formData(url, data) { var headers = new Headers(), authtoken = localStorage.getItem('authtoken'); if (authtoken) { headers.append("Authorization", 'Token ' + authtoken) } headers.append("Accept", 'application/json'); headers.delete("Content-Type"); var requestoptions = new RequestOptions({ method: RequestMethod.Post, url: this.apiURL + url, headers: headers, body: data }) return this.http.request(new Request(requestoptions)) .map((res: Response) => { if (res

Image upload ajax jquery

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im new to jQuery. I try to upload a jpg image file by using ajax method. But when I upload, it doesn't upload. Could anyone please help me to do this? HTML <form action="" method="POST" enctype="multipart/form-data"> <input type="file" name="image" id="image"/> </form> jQuery $('#submit').click(function() { var image=$('#image').val() $.post("upload.php",{image:image},function(data) { alert(data); }); } }) PHP <?php $image=$_POST['image']; $imagename=date("d-m-Y")."-".time()."jpg"; $target_path = "uploads/".$imagename; if(move_uploaded_file(

path and formData paramter at the same time

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i want to upload a image to my API endpoint. the endpoint should be /test/{id}/relationships/image . i want to describe with swagger path and formData parameters at the same time. my swagger yaml file looks like this: swagger: '2.0' info: title: API version: 1.0.0 host: api.server.de schemes: - https produces: - application/json paths: '/test/{id}/relationships/image': post: operationId: addImage consumes: - multipart/form-data parameters: - in: path name: id required: true schema: type: integer format: int32 - in: formData name: file type:

Ajax FileUpload &amp; JQuery formData in ASP.NET MVC

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some problem with posting formData to server side action method. Because ajax call doesn't send files to server, I have to add file uploader data to formData manually like this: var formData = new FormData(); formData.append("imageFile", $("#imageFile").file); formData.append("coverFile", $("#coverFile").file); I wrote jQuery function that need to post form data to server using ajax call. It's works but posted formData in server side is always null! this is my script: Edit 1: This is the action method in controller: public

TypeError: Cannot read property &#039;jquery&#039; of undefined

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting the following error in Chrome console, TypeError: Cannot read property 'jquery' of undefined Here is my javascript function, <script type="text/javascript"> var formApp = angular.module('formApp',[]); function formController($scope,$http){ $scope.formData = {}; $scope.processForm = function(){ $http({ method : 'POST', url : 'http://localhost:8080/ABCAPI/v1/image/front', data : $.param($scope.formData.imageFile), headers : {'Content-Type': "multipart/form-data" , 'Auth-Token' : "X"} }).success(function(data){ console.log(""); if (