色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net MVC實現簡單的上傳功能

方法一:
Home/Index.ASPx中的代碼
復制代碼 代碼如下:
<% using (Html.BeginForm("up","Home",FormMethod.Post,new{enctype="multipart/form-data"})) {%>
<input type="file" name="upfile" />
<input type ="submit" name ="upload" value ="上傳" />
<%} %>

Homecontroller中的代碼
[code]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult up(HttpPostedFileBase upfile)
{
if (upfile != null)
{
if (upfile.ContentLength > 0)
{
upfile.SaveAs("d://7.jpg");
}
}
return RedirectToAction("Index");
}

方法二:



Home/Index.ASPx中的代碼
復制代碼 代碼如下:
<form action="<%=Url.Action("upload2") %>" enctype="multipart/form-data" method="post">
<input name="up1" type="file" /><input type="submit" />
</form>

Homecontroller中的代碼
復制代碼 代碼如下:
public ActionResult upload2(HttpPostedFileBase up1)
{
up1.SaveAs("d://8.jpg");
return Content(up1.FileName);
}

AspNet技術asp.net MVC實現簡單的上傳功能,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 黄平县| 九台市| 五原县| 宜兴市| 吴江市| 工布江达县| 运城市| 上犹县| 冷水江市| 安西县| 长兴县| 海林市| 中宁县| 正定县| 延川县| 青铜峡市| 江陵县| 富顺县| 宁陵县| 天水市| 甘南县| 南投市| 浮梁县| 余干县| 三门县| 张家港市| 谢通门县| 开封市| 辽阳县| 五华县| 营山县| 阿荣旗| 临城县| 永定县| 古交市| 阳江市| 藁城市| 黄陵县| 筠连县| 桃源县| 铜川市|