ios客户端上传图片到asp.net

来源:互联网 发布:bs编程是什么意思 编辑:程序博客网 时间:2024/05/08 14:10


这是网上找的代码 ,自己实践了一下。

1. protected void Page_Load(object sender, EventArgs e)

  2. {

  3.     if (Request.Files.Count == 0)

  4.     {

  5.         Response.Write("none file");

  6.     }

  7.     else

  8.     {

  9.         HttpPostedFile file = Request.Files["img"];

  10.         String filename = Request.Form["name"];

  11.         file.SaveAs(MapPath("~/"+filename+".png"));

  12.

  13.         Response.Write("ok");

  14.     }

  15. }


网上有个资料文档:

http://blog.csdn.net/li6185377/article/details/8540884

http://www.2cto.com/kf/201303/198983.html

第一次没成功,然后用try  catch 获取异常发现是路径问题。。。

特别提醒:  保存图片的路径一点要是虚拟路径   “  ~/ ”  。


 
原创粉丝点击