我有一个剑道上传和一个按钮,我想在点击按钮上传时使用kendo文件上传文件。
当我调试我的动作方法时,httppostefile返回null。
这是我的行动方法。
int rows = 7; int cols = 7;
List<String> previous = new List<String>(rows);
for(int x=0; x<=rows; x++) {
// if beginning of row has already been calculated then print it out
if ( previous[y] != null) System.out.print(previous);
// then start at X to calculate the rest of the row
for(int y=x; y<=cols; y++){
System.out.print(x*y);
previous[y] += " " + x*y;
}
}
查看
[HttpPost]
public ActionResult UploadHactAssesmentAttachment(IEnumerable<HttpPostedFileBase> Files)
{
TBL_ASST_HACTA_ATTACHMENT obj = new TBL_ASST_HACTA_ATTACHMENT();
foreach (var file in Files)
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/ProjectUploadedDocuments"), fileName);
obj.FilePath = path;
obj.CreatedDateTime = DateTime.Now;
obj.CreatedByID = Convert.ToInt32(Session["UserID"]);
dbcontext.TBL_ASST_HACTA_ATTACHMENT.Add(obj);
file.SaveAs(path);
dbcontext.SaveChanges();
}
}
return RedirectToAction("Index");
}
答案 0 :(得分:0)
要上传文件async
,无需将@(Html.Kendo().Upload())
包裹在form
中
因为Upload
使用HTML5文件API(w3,wiki),因此剑道团队还为旧浏览器提供了后备。所以最简单的方法是:
<div class="row">
<div class="col-lg-3">
@(Html.Kendo().Upload()
.Name("files")
.Async(a => a
.Save("UploadHactAssesmentAttachment", "Upload")
.Remove("Remove", "Upload")//You need to implement it too
.AutoUpload(true)
)
)
</div>
</div>
我认为看看他们的docs也可能会有所帮助。
希望它能够结束。