473,623 Members | 2,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebRequest Upload File

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=multipa rt/form-data> File to
post<input name="FileData" type="file" size="32"><inpu t type=submit
value="Post file to mailbox"></form>

thanks for your help
Nov 16 '05 #1
4 9711
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]
- mv*@spam.guard. caspershouse.co m

"Shawn Mesiatowsky" <sh***@nospam.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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=multipa rt/form-data> File to
post<input name="FileData" type="file" size="32"><inpu t type=submit
value="Post file to mailbox"></form>

thanks for your help

Nov 16 '05 #2
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 [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:e8******** ******@TK2MSFTN GP14.phx.gbl...
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]
- mv*@spam.guard. caspershouse.co m

"Shawn Mesiatowsky" <sh***@nospam.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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=multipa rt/form-data> File to
post<input name="FileData" type="file" size="32"><inpu t type=submit
value="Post file to mailbox"></form>

thanks for your help


Nov 16 '05 #3
Shawn,

Yes, it will. Check out the UploadFile method on the WebClient class.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Shawn Mesiatowsky" <sh***@nospam.c om> wrote in message
news:eZ******** ******@tk2msftn gp13.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in
message news:e8******** ******@TK2MSFTN GP14.phx.gbl...
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]
- mv*@spam.guard. caspershouse.co m

"Shawn Mesiatowsky" <sh***@nospam.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
>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=multipa rt/form-data> File to
> post<input name="FileData" type="file" size="32"><inpu t type=submit
> value="Post file to mailbox"></form>
>
> thanks for your help
>
>



Nov 16 '05 #4
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.as px">
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 [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:ep******** ******@TK2MSFTN GP12.phx.gbl...
Shawn,

Yes, it will. Check out the UploadFile method on the WebClient class.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Shawn Mesiatowsky" <sh***@nospam.c om> wrote in message
news:eZ******** ******@tk2msftn gp13.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote
in
message news:e8******** ******@TK2MSFTN GP14.phx.gbl...
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]
- mv*@spam.guard. caspershouse.co m

"Shawn Mesiatowsky" <sh***@nospam.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
>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=multipa rt/form-data> File to
> post<input name="FileData" type="file" size="32"><inpu t type=submit
> value="Post file to mailbox"></form>
>
> thanks for your help
>
>



Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4955
by: Katie | last post by:
I am attempting to write an Ftp Client to send a quote command prior to a file upload. I would like to use the WinInet.dll but it seems to hang when I call the FtpCommand method from C# or it returns a false response even though the command was successful. I have also attempted to inherit from the WebRequest and WebResponse classes based on examples I have found on the internet but it hangs when the socket goes to read whether the...
1
1446
by: umeshayk | last post by:
Respected Sir What ever you have explained on WebRequest and WebResponse I came to know very well.I started to implement a project based on this concept.What i did was 1. I used Webrequest to hit the starting page of the website to get the Cookie value(www.ichotelsgroup.com) (I am getting Cookie Value = "JSESSIONID=Q1FXQVIIYWOVPLAQ5U0SJ0VMCD4VOIY4 ; domain=.ichotelsgroup.com; path=/") 2.Then I used WebClient to upload values to Next...
8
2394
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the references available but to no avail Also, is it safer (better practise) in an LAN environment to use HTTP requests to access shared files (via ASP.NET) rather than UNC file shares TIA Regards John
4
7223
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
2
5964
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an application to download images using System.NET classes (webclient, webrequest) asynchronously behind proxy server. The reading method works like this: System.Net.WebClient client=new System.Net.WebClient();
2
8040
by: SharpCoderMP | last post by:
I'm having troubles with uploading files to the ftp server using FtpWebRequest. I occasionally get an Exception saying: "The underlying connection was closed: An unexpected error occurred on a receive". but what's wired i get this exception just after upload is finished when i try to close the stream that was used for upload. this happens only when upload takes more that certain amount of time. note that upload itself goes smooth no matter...
4
1068
by: RobAMacAF | last post by:
I am using this... string url = "http://digi-wiz.com/uploads/upload/Nouns"; string result = null; WebClient client = new WebClient(); result = client.DownloadString( url ); MessageBox.Show(result); Which is very basic code. It just looks at the files in the http://digi-wiz.com/uploads/upload/Nouns
4
2071
by: CindyH | last post by:
Hi I'm trying to use webrequest - webresponse to post a stream. I have set up a simple test with one aspx form holding the post code and trying to get another aspx form to receive the post on localhost. Can you explain to me the possible reasons why a 'GetResponse' - to send the data to a server might not be working for a simple text file with one line. test.text - contains: this is a test.
2
4367
by: Piotrekk | last post by:
Hi I am trying to upload a 700 mb file using webrequest/response model. At 3x% I am getting the same error: "Unable to write data to the transport connection: an established connection was aborted by the software in your host machine" CLIENT side script is:
0
8227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8165
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8670
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4074
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4164
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2602
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1778
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.