日期:2014-05-18 浏览次数:20792 次
/// <summary> /// Uploader 的摘要说明 /// </summary> public class Uploader : IHttpHandler { public void ProcessRequest(HttpContext context) { try { string newFileName = context.Request.QueryString["n"]; foreach (string keyString in context.Request.Files) { HttpPostedFile file = context.Request.Files[keyString]; //string newName = newFileName; file.SaveAs(Path.Combine(context.Server.MapPath("/img"), newFileName)); } } catch (Exception ex) { context.Response.Write(ex.Message); } } public bool IsReusable { get { return true; } } }
------解决方案--------------------
在服务器端建个web服务也可以
------解决方案--------------------
WebClient uploadClient = new WebClient();
// 如果不需要用户名和密码,以下两行可以不要
NetworkCredential myNetworkCredential = new NetworkCredential(userName, passwork);
uploadClient.Credentials = myNetworkCredential;
uploadClient.UploadFile(serverPicturePath, localPicturePath);
------解决方案--------------------