如何使用httppost方法在html中上传多个文件? [英] how to upload multiple files in html using httppost method?

查看:301
本文介绍了如何使用httppost方法在html中上传多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <   pre  >  
< 表格 action = 主页/上传 方法 = 发布 enctype = multipart / form-data >
< label = photo > 照片:< / label >
< 输入 < span class =code-attribute> type = file name = [0] .files id = files_0 / >
< 输入 type = file name = [1] .files id = files_1 / >
< 输入 type = file 名称 = [2 ] .files id = files_2 / >
< input type = submit value = 上传 / >
< / form >
< / pre >
[HttpPost]
public ActionResult Upload(IEnumerable < HttpPostedFileBase > 文件)
{
foreach(文件中的var文件)
{
file.SaveAs(...);
}
返回RedirectToAction(Index);
}





这里的文件我得到null我没有得到任何文件(图像)

解决方案

在此处查找: ASP-NET-MVC-Working-With-Files-using-Csharp [ ^ ]


尝试

上传文件(使用ASP.NET MVC [ ^ ]

使用ASP.NET MVC实现HTTP文件上载 [ ^ ] br />
在ASP.NET中上传和返回文件MVC [ ^ ]

<pre>
<form action="Home/upload" method="post" enctype="multipart/form-data">
<label for="photo">Photo:</label>
<input type="file" name="[0].files" id="files_0" />
<input type="file" name="[1].files" id="files_1" />
<input type="file" name="[2].files" id="files_2" />
<input type="submit" value="Upload" />
</form>
</pre>
[HttpPost]
public ActionResult Upload(IEnumerable<HttpPostedFileBase> files)
{
foreach(var file in files)
{
file.SaveAs(...);
}
return RedirectToAction("Index");
}



here files I am getting null I am not getting any files(images)

解决方案

Find out here: ASP-NET-MVC-Working-With-Files-using-Csharp[^]


Try
Uploading a File (Or Files) With ASP.NET MVC[^]
Implementing HTTP File Upload with ASP.NET MVC[^]
Uploading and returning files in ASP.NET MVC[^]


这篇关于如何使用httppost方法在html中上传多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆