Uploading files using WebClient

  • Thread starter Thread starter Mariela
  • Start date Start date
M

Mariela

I am trying to run the following C# code:
----------------------------------------
String uriString = "http://10.1.1.100/images/";
WebClient myWebClient = new WebClient();
string fileName = "C:\\agoodfriend.jpg";
byte[] responseArray = myWebClient.UploadFile
(uriString,"POST",fileName);
----------------------------------------

But I get the following error:

Exception Details: System.Net.WebException: The remote
server returned an error: (405) Method Not Allowed.

Does anyone know why this happens?

I suspected it was a permission thing. I tried enabling
the directory to be written, but it didn't work.

Thanks in advance for the help
 
the uriString you supply has to support file uploads. the one you supplied
did not.

did you write a page to receive the file, or install some file upload
support software on you web server?

-- bruce (sqlwork.com)
 
Are you attempting to upload files using the multipart/form-data encoding?
If so

1. Your client needs to send data using this protocol and format
2. The server needs to have something that supports this as well.
 
Back
Top