C#(WinForm)上传图片到服务器
//本地上传代码Files item = fis as Files;
WebClient wc = new WebClient();
string url = stringFormat("{0}Overwrite=true&Path={1}", "服务器上传地址", itemPath);
wcUploadFile(url, "POST", itemPath);
//服务器接收
string ServerSrc = contextServerMapPath("~/DownLogin/");
foreach (string filekey in contextRequestFiles)
{
HttpPostedFile file = contextRequestFiles[filekey];
string FilePath = PathCombine(ServerSrc, fileFileName);
if (FileExists(FilePath))
{
if (ConvertToBoolean(contextRequest["overwrite"]))
{
FileDelete(FilePath);
}
else
continue;
}
fileSaveAs(FilePath);
}
0条评论