Uploading files using WebClient

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
 
B

bruce barker

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)
 
S

Shiv Kumar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top