WebRequest Upload File

  • Thread starter Thread starter Shawn Mesiatowsky
  • Start date Start date
S

Shawn Mesiatowsky

I have an html form that accepts a file for uploading, but I wanted to
create a program to automate the upload procedure.
I beileive you use the Webresponse class, but I was not sure how to use this
class to post a file to a specified website. In some documentation I have,
it also specifies the Request Header must be: Content-type:
application/octet-stream
here is the web site html code:

<form action=post method=post enctype=multipart/form-data> File to
post<input name="FileData" type="file" size="32"><input type=submit
value="Post file to mailbox"></form>

thanks for your help
 
Shawn,

If you don't have to set cookies or anything of that nature, then you
could probably use the WebClient class to handle this. It will automate the
uploading of files to a server.

Hope this helps.
 
I thought the WebClient was used for uploading files to the webserver, such
as updating web pages, etc. But I need to pass the file to a server as a
post request, not just to put a file on a server. can the Webclient do this
as well?
Nicholas Paldino said:
Shawn,

If you don't have to set cookies or anything of that nature, then you
could probably use the WebClient class to handle this. It will automate the
uploading of files to a server.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Shawn Mesiatowsky said:
I have an html form that accepts a file for uploading, but I wanted to
create a program to automate the upload procedure.
I beileive you use the Webresponse class, but I was not sure how to use
this
class to post a file to a specified website. In some documentation I have,
it also specifies the Request Header must be: Content-type:
application/octet-stream
here is the web site html code:

<form action=post method=post enctype=multipart/form-data> File to
post<input name="FileData" type="file" size="32"><input type=submit
value="Post file to mailbox"></form>

thanks for your help
 
Shawn,

Yes, it will. Check out the UploadFile method on the WebClient class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Shawn Mesiatowsky said:
I thought the WebClient was used for uploading files to the webserver, such
as updating web pages, etc. But I need to pass the file to a server as a
post request, not just to put a file on a server. can the Webclient do
this
as well?
in
message news:[email protected]...
Shawn,

If you don't have to set cookies or anything of that nature, then you
could probably use the WebClient class to handle this. It will automate the
uploading of files to a server.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Shawn Mesiatowsky said:
I have an html form that accepts a file for uploading, but I wanted to
create a program to automate the upload procedure.
I beileive you use the Webresponse class, but I was not sure how to use
this
class to post a file to a specified website. In some documentation I have,
it also specifies the Request Header must be: Content-type:
application/octet-stream
here is the web site html code:

<form action=post method=post enctype=multipart/form-data> File to
post<input name="FileData" type="file" size="32"><input type=submit
value="Post file to mailbox"></form>

thanks for your help
 
The UploadFile method requires 2 parameters, the first being the location of
the file location you are trying to upload. Do i just specify the webpage
file that the form posts to?
for instance, if I have a form on a server in form.html:
<form action="post.aspx">
then do I specify the uri like this: http://www.company.com/post.aspx

I had just assumed that the first parameter was for uploading a file you
want to store on a server, for instance,

If I had edited index.html and wanted to upload the page to
www.company.com/index.html then I would use the webclient.

Am I wrong on this? the reason I just do not test is because it is a third
party that is hosting the site, and I have no facility for testing, unless a
create some web app myself that accepts files. Thanks for your help so far
Nicholas.


Nicholas Paldino said:
Shawn,

Yes, it will. Check out the UploadFile method on the WebClient class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Shawn Mesiatowsky said:
I thought the WebClient was used for uploading files to the webserver, such
as updating web pages, etc. But I need to pass the file to a server as a
post request, not just to put a file on a server. can the Webclient do
this
as well?
in
message news:[email protected]...
Shawn,

If you don't have to set cookies or anything of that nature, then you
could probably use the WebClient class to handle this. It will
automate
the
uploading of files to a server.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have an html form that accepts a file for uploading, but I wanted to
create a program to automate the upload procedure.
I beileive you use the Webresponse class, but I was not sure how to use
this
class to post a file to a specified website. In some documentation I have,
it also specifies the Request Header must be: Content-type:
application/octet-stream
here is the web site html code:

<form action=post method=post enctype=multipart/form-data> File to
post<input name="FileData" type="file" size="32"><input type=submit
value="Post file to mailbox"></form>

thanks for your help
 
Back
Top