mvc中的问题上传文件 [英] problem upload file in mvc
本文介绍了mvc中的问题上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想上传一个文件,但没有参数值为什么?
i want a upload a file but no parameter value why?
@using (Ajax.BeginForm("addfilezamimeh","letter", new { id = 90 }, new AjaxOptions { HttpMethod = "post", UpdateTargetId = "divAjax", InsertionMode = InsertionMode.Replace }, new { enctype = "multipart/form-data" }))
{ <input type="file" id="filex" />
<input type="submit" value="nnnnnnnnnn" />
<div id="divAjax"></div>
}
[HttpPost]
public ActionResult addfilezamimeh(int id,HttpPostedFileBase filex)
{
foreach (string upload in Request.Files)
{
}
}
推荐答案
你不能像这样使用ajax上传文件。一些可能的解决方案谷歌c#mvc异步上传。你可以使用各种javascript插件或使用html5来做到这一点,但你不能使用基本的jQuery ajax(这是Ajax.BeginForm使用的)。
You can't upload files using ajax like that. Google "c# mvc async upload" for some possible solutions. You can do this using various javascript plug-ins or using html5, but you can't do it using basic jQuery ajax (which is what Ajax.BeginForm uses).
这篇关于mvc中的问题上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文