PLEASE HELP: uplaoding files from HTTP server using webrequest

A

amine

Hi all,

I have been developing an application for an IPAQ.
I am trying to write some code that will allow the user to
upload files to an HTTP server. I of course can't use the
webclient class since it is not supported by the compact
framework.
is there anyway I can use the webrequest and webresponse
classes to upload files from the httpserver.

I got this snippet of code from a site but it doenst work:

webrequest req = webrequest.create (url);
req.method = "put";
String temp_file_content ="file content";

byte[] encoded_content = Encoding.UTF8.GetBytes
(temp_file_content);
req.ContentLength = encoded_content.Length;

Stream request_stram = r4eq.GetRequestStream();
request_stream.Write (encoded_content, 0 ,
encoded_content.Length);
request_stram.Close();

PLEASE any help is very appreciated since I have looked
all over and couldnt find anything. I am very desperate

Thank You.
 
J

Joerg Jooss

amine said:
Hi all,

I have been developing an application for an IPAQ.
I am trying to write some code that will allow the user to
upload files to an HTTP server. I of course can't use the
webclient class since it is not supported by the compact
framework.
is there anyway I can use the webrequest and webresponse
classes to upload files from the httpserver.

I got this snippet of code from a site but it doenst work:

webrequest req = webrequest.create (url);
req.method = "put";
String temp_file_content ="file content";

byte[] encoded_content = Encoding.UTF8.GetBytes
(temp_file_content);
req.ContentLength = encoded_content.Length;

Stream request_stram = r4eq.GetRequestStream();
request_stream.Write (encoded_content, 0 ,
encoded_content.Length);
request_stram.Close();

PLEASE any help is very appreciated since I have looked
all over and couldnt find anything. I am very desperate


HTTP PUT only works if the web server is configured to allow that.
Otherwise you have to use HTTP POST, but that requires some server-side
component (ASP.NET, JSP, PHP, ...) to process the request.

Cheers,
 

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

Top