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

asp.net MVC實(shí)現(xiàn)簡單的上傳功能

方法一:
Home/Index.ASPx中的代碼
復(fù)制代碼 代碼如下:
<% 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中的代碼
復(fù)制代碼 代碼如下:
<form action="<%=Url.Action("upload2") %>" enctype="multipart/form-data" method="post">
<input name="up1" type="file" /><input type="submit" />
</form>

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

AspNet技術(shù)asp.net MVC實(shí)現(xiàn)簡單的上傳功能,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 镇巴县| 明光市| 邯郸市| 太和县| 明溪县| 怀柔区| 东阿县| 门源| 易门县| 昌江| 涿鹿县| 台东市| 南溪县| 开封县| 梁平县| 辽宁省| 临江市| 太仆寺旗| 抚远县| 谷城县| 栾城县| 泸水县| 海阳市| 环江| 斗六市| 宝坻区| 精河县| 毕节市| 曲靖市| 石嘴山市| 临泉县| 广昌县| 延长县| 瑞昌市| 吉木萨尔县| 湟源县| 团风县| 镇赉县| 新源县| 察隅县| 汉阴县|