everyone. I’m programming with c# language and I have a problem with WebClient class.
I downloaded an image by using method WebClient.DownloadData, it worked fine. But, WebClient.UploadData didn’t.
In details, I have a byte[] contains a image’s content – named bytes, and an URL of image folder which I want to upload to – named filePath. then,
WebClient wc = new WebClient();
byte[] responseArray = wc.UploadData(filePath, "POST", bytes);
And it return back to me following error
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)
at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data)
at System.Net.WebClient.UploadData(String address, String method, Byte[] data)
I also researched some solutions for this problem, however none of them worked for me. 🙁
Please help! :-s
try this page. It has a posting example.
It uses webrequest rather that webclient, but it is from microsoft and should be a good example.
i slimmed down the code and commented the sections you will want to look at.
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx