C# .NET Uploading file to a web form using HttpWebRequest

不羁岁月 提交于 2019-12-30 11:07:36

问题


Does anyone have a working example using HttpWebRequest in C# to submit a file from the local drive to a multipart/form-data web form?


回答1:


it is WAY easier to do this with WebClient

string url = "http://myserver/myapp/upload.aspx";
string file = "c:\\files\\test.jpg";
WebClient wc = new WebClient();
wc.UploadFile(url,"post",file);

If it needs to be httpwebrequest I can put something together for you (it is possible), but it will be more like 50 lines then 5



来源:https://stackoverflow.com/questions/342453/c-sharp-net-uploading-file-to-a-web-form-using-httpwebrequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!