我如何发布表单数据和图像 [英] How I can post form data along with image
本文介绍了我如何发布表单数据和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@ using(Html.BeginForm( UploadAction1, Media,FormMethod.Post, new {enctype = multipart / form-data,id = frmID}))
{}
$(document).ready(function(){
$(' #fileupload')。fileupload({
dataType:' json' ,
url:' / Media / UploadFiles1',
autoUpload: true ,
singleFileUploads: false ,
完成:函数(e,数据){
}
})。on(' fileuploadprogressall',函数(e,data){
var progress = parseInt(data.loaded / data.total * 100 , 10 );
$(' .progress .progress-bar')。css(' width',progress + ' %跨度>);
});
});
我正在使用fileupload插件,我想要 发布formdata和图片。
这样的东西应该可以工作
数据: $(' #frmID')。serialize()
,>
我使用Request.Files获取图像值但我无法发布任何数据。
https://github.com/blueimp/jQuery-File-Upload/wiki/Options [ ^ ]
解决方案
(document).ready(function(){
(' #fileupload')。fileupload({
dataType:' JSON'跨度>,
url:' / Media / UploadFiles1',
autoUpload:< span class =code-keyword> true ,
singleFileUploads: false ,
done:function(e,data){
}
})。on(' fileuploadprogressall',函数(e,data){
var progress = parseInt(data.loaded / data.total * 100 , 10 );
(' .progress .progress-bar')。css(' width' ,progress + ' %');
});
});
我正在使用fileupload插件,我想要 发布formdata和图片。
这样的东西应该可以工作
数据:
@using (Html.BeginForm("UploadAction1", "Media", FormMethod.Post, new { enctype = "multipart/form-data", id = "frmID" }))
{}
$(document).ready(function () {
$('#fileupload').fileupload({
dataType: 'json',
url: '/Media/UploadFiles1',
autoUpload: true,
singleFileUploads: false,
done: function (e, data) {
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('.progress .progress-bar').css('width', progress + '%');
});
});
I am using fileupload plugin , where i want to post formdata along with image.
something like this should work
data: $('#frmID').serialize()
,
I am getting image values using Request.Files but I am unable to post any data.
https://github.com/blueimp/jQuery-File-Upload/wiki/Options[^]
解决方案
(document).ready(function () {
('#fileupload').fileupload({ dataType: 'json', url: '/Media/UploadFiles1', autoUpload: true, singleFileUploads: false, done: function (e, data) { } }).on('fileuploadprogressall', function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10);
('.progress .progress-bar').css('width', progress + '%'); }); });
I am using fileupload plugin , where i want to post formdata along with image.
something like this should work
data:
这篇关于我如何发布表单数据和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文