色尼玛亚洲综合影院,亚洲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實現簡單的上傳功能,轉載需保留來源!

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

主站蜘蛛池模板: 南丹县| 资兴市| 鱼台县| 蒲城县| 台南市| 望奎县| 禄丰县| 东辽县| 衡阳县| 潞西市| 平安县| 财经| 土默特右旗| 溧水县| 鄂伦春自治旗| 山丹县| 剑阁县| 淳安县| 常熟市| 榕江县| 鹤山市| 翁牛特旗| 思茅市| 沂水县| 华坪县| 马公市| 壤塘县| 建水县| 哈巴河县| 万安县| 景泰县| 奉化市| 五常市| 偃师市| 阿合奇县| 行唐县| 祁东县| 黑水县| 萝北县| 宣城市| 泸西县|