winform客户端上传图片或文件到web服务器

System.Net.WebClient myWebClient = new System.Net.WebClient();//声明变量

//rweb路径 = "http://localhost:1473/servfilechuli.ashx"网络路径

//rweb路径 = "http://localhost:1473/servfilechuli.ashx?xxx=xxx&zzz=zzz..."网络路径带参
 myWebClient.UploadFile("web路径可以带参数", "POST","本地文件路径")

//上面调用就结束了,后面的处理就是web上的了

context.Response.ContentType = "text/plain";

            string strMethod = context.Request["Method"].ToString().Trim();

            object objFanHuiZhi = "";
            string strFanHuiShuJu = "";
            int nret = 0;
            string strData = "";

            //Method入参的时候加个这个说明下面要执行的方法名这个可以自己随便命名,不弄也行
            if (strMethod == "ShangChuanTuPian")
            {
                string strBaoCunLuJing = context.Request["strBaoCunLuJing"].ToString().Trim();//入的其他参数
                string strBaoCunTuPianName =                              context.Request["strBaoCunTuPianName"].ToString().Trim();//入的其他参数
                HttpPostedFile file = context.Request.Files[0];//入参的文件

            }

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值