473,564 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload a text file thru webclient

Hi
i am trying to upload a txt file thru this code, but its not updating
the data. is this code fine.
Or can anybody please suggest me some other meathod to do the same.
its urgent please help

regards
shantanu

WebClient client = new WebClient();
client.Credenti als = netCred;
client.Headers. Add("Content-Type","applicat ion/x-www-form-
urlencoded");
client.UploadFi le("http://aww.ngn.bel.alc atel.be/prp/cgi-bin/secure/
ImportForm.cgi" ,"POST",@"C:\PR P\PRPTemp.txt") ;

Jun 20 '07 #1
12 2071
Hi,

It seems fine to me , what problems are you getting?

"shantanu" <sh***********@ gmail.comwrote in message
news:11******** **************@ i38g2000prf.goo glegroups.com.. .
Hi
i am trying to upload a txt file thru this code, but its not updating
the data. is this code fine.
Or can anybody please suggest me some other meathod to do the same.
its urgent please help

regards
shantanu

WebClient client = new WebClient();
client.Credenti als = netCred;
client.Headers. Add("Content-Type","applicat ion/x-www-form-
urlencoded");
client.UploadFi le("http://aww.ngn.bel.alc atel.be/prp/cgi-bin/secure/
ImportForm.cgi" ,"POST",@"C:\PR P\PRPTemp.txt") ;

Jun 20 '07 #2
On Jun 20, 5:28 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
Hi,

It seems fine to me , what problems are you getting?

"shantanu" <shantanuse...@ gmail.comwrote in message

news:11******** **************@ i38g2000prf.goo glegroups.com.. .
Hi
i am trying to upload a txt file thru this code, but its not updating
the data. is this code fine.
Or can anybody please suggest me some other meathod to do the same.
its urgent please help
regards
shantanu
WebClient client = new WebClient();
client.Credenti als = netCred;
client.Headers. Add("Content-Type","applicat ion/x-www-form-
urlencoded");
client.UploadFi le("http://aww.ngn.bel.alc atel.be/prp/cgi-bin/secure/
ImportForm.cgi" ,"POST",@"C:\PR P\PRPTemp.txt") ;- Hide quoted text -

- Show quoted text -
hi thanx for the reply
i am really confused it is giving no error
can there be any posibility of acess rights
the link has GUI with a file upload option ans a import button.
regards
shantanu

Jun 20 '07 #3
From your description, this is a standard user page (since you mention
GUI); I'd be inclined to upload a file via a browser, with "fiddler"
running to see what gets sent - looking in particular at any
additional form variables, cookies, etc. You can probably get as much
by looking at the form, but "fiddler" may be easier, especially since
this is http not https (although fiddler 2 works with SSL in IE)

Marc
Jun 20 '07 #4
On Jun 20, 7:34 pm, "Marc Gravell" <marc.grav...@g mail.comwrote:
From your description, this is a standard user page (since you mention
GUI); I'd be inclined to upload a file via a browser, with "fiddler"
running to see what gets sent - looking in particular at any
additional form variables, cookies, etc. You can probably get as much
by looking at the form, but "fiddler" may be easier, especially since
this is http not https (although fiddler 2 works with SSL in IE)

Marc
Hi thanks for the reply but i actually did not get the answer, what is
fiddler ????
is it any tool that give me a strack trace of the communication?? ???

thanks shantanu

Jun 20 '07 #5
On Jun 21, 1:27 am, Marc Gravell <marc.grav...@g mail.comwrote:
Exactly:http://www.fiddlertool.com/Fiddler/version.asp
orhttp://www.fiddler2.co m/fiddler2/

Marc
hi i tried with the fiddler tool
i am posting the trace can u tell whats the diffrence as i am not
getting it
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++
+++++++++++++++ +
>From Excel
POST /prp/cgi-bin/secure/ImportForm.cgi HTTP/1.1

Content-Type: multipart/form-data;
boundary=---------------------8c981ff4727edcc

Content-Length: 1770

Expect: 100-continue

Host: aww.ngn.bel.alc atel.be

HTTP/1.1 100 Continue

-----------------------8c981ff4727edcc

Content-Disposition: form-data; name="file"; filename="PRPTe mp.txt"

Content-Type: application/x-www-form-urlencoded

number.name.con tent.original.c ontent.approved .content.planne d.contentdelete d.original.cont entdeleted.appr oved.contentdel eted.planned.co ntentchange.ori ginal.contentch ange.approved.c ontentchange.pl anned.defectsdo c.original.defe ctsdoc.approved .defectsdoc.pla nned.defectscod e.original.defe ctscode.approve d.defectscode.p lanned.defectst est.original.de fectstest.appro ved.defectstest .planned.defect sval.original.d efectsval.appro ved.defectsval. planned.defects fieldsw.origina l.defectsfields w.approved.defe ctsfieldsw.plan ned.effort.orig inal.effort.app roved.effort.pl anned.effortdr1 dr5.original.ef fortdr1dr5.appr oved.effortdr1d r5.planned.defe ctsfielddr5.ori ginal.defectsfi elddr5.approved .defectsfielddr 5.planned.nrcus tomers.original .nrcustomers.ap proved.nrcustom ers.planned.sal esvalue.origina l.salesvalue.ap proved.salesval ue.planned.marg in.original.mar gin.approved.ma rgin.planned.dr 0p.original.dr0 p.approved.dr0p .planned.dr0p.s tatus.dr1.origi nal.dr1.approve d.dr1.planned.d r1.status.dr3.o riginal.dr3.app roved.dr3.plann ed.dr3.status.d r4.original.dr4 .approved.dr4.p lanned.dr4.stat us.dr5.original .dr5.approved.d r5.planned.dr5. status.dr6.orig inal.dr6.approv ed.dr6.planned. dr6.status.dr0. original.dr0.ap proved.dr0.plan ned.dr0.status. dr2.original.dr 2.approved.dr2. planned.dr2.sta tus.ci.original .ci.approved.ci .planned.ci.sta tus.obr.origina l.obr.approved. obr.planned.obr .status.release type.location.l ocationlead.pl.

9YZ-00490-
AAAA.TestProjec t.............. ............... ............... .............
2009-02-04....2009-12-12....2009-08-21....2009-09-19....2009-03-27............. L36051.
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++
+++++++++++++++ ++
>From Portal
POST /prp/cgi-bin/secure/Import.cgi HTTP/1.1

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-powerpoint,
application/vnd.ms-excel, application/msword, application/xaml+xml,
application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-
ms-application, */*

Referer: http://aww.ngn.bel.alcatel.be/prp/cg...L36051&root=AL

Accept-Language: en-us

Content-Type: multipart/form-data;
boundary=---------------------------7d722727054c

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)

Host: aww.ngn.bel.alc atel.be

Content-Length: 2155

Connection: Keep-Alive

Cache-Control: no-cache

Authorization: Basic c2hhbnRhbnUgc2V uOnN1bm55IzAwMw ==

-----------------------------7d722727054c

Content-Disposition: form-data; name="file"; filename="C:\PR P
\PRPTemp.txt"

Content-Type: text/plain

number.name.con tent.original.c ontent.approved .content.planne d.contentdelete d.original.cont entdeleted.appr oved.contentdel eted.planned.co ntentchange.ori ginal.contentch ange.approved.c ontentchange.pl anned.defectsdo c.original.defe ctsdoc.approved .defectsdoc.pla nned.defectscod e.original.defe ctscode.approve d.defectscode.p lanned.defectst est.original.de fectstest.appro ved.defectstest .planned.defect sval.original.d efectsval.appro ved.defectsval. planned.defects fieldsw.origina l.defectsfields w.approved.defe ctsfieldsw.plan ned.effort.orig inal.effort.app roved.effort.pl anned.effortdr1 dr5.original.ef fortdr1dr5.appr oved.effortdr1d r5.planned.defe ctsfielddr5.ori ginal.defectsfi elddr5.approved .defectsfielddr 5.planned.nrcus tomers.original .nrcustomers.ap proved.nrcustom ers.planned.sal esvalue.origina l.salesvalue.ap proved.salesval ue.planned.marg in.original.mar gin.approved.ma rgin.planned.dr 0p.original.dr0 p.approved.dr0p .planned.dr0p.s tatus.dr1.origi nal.dr1.approve d.dr1.planned.d r1.status.dr3.o riginal.dr3.app roved.dr3.plann ed.dr3.status.d r4.original.dr4 .approved.dr4.p lanned.dr4.stat us.dr5.original .dr5.approved.d r5.planned.dr5. status.dr6.orig inal.dr6.approv ed.dr6.planned. dr6.status.dr0. original.dr0.ap proved.dr0.plan ned.dr0.status. dr2.original.dr 2.approved.dr2. planned.dr2.sta tus.ci.original .ci.approved.ci .planned.ci.sta tus.obr.origina l.obr.approved. obr.planned.obr .status.release type.location.l ocationlead.pl.

9YZ-00490-
AAAA.TestProjec t.............. ............... ............... .............
2009-02-04....2009-12-12....2009-08-21....2009-09-19....2009-03-27............. L36051.

+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++
+++++++++++++++ +

Jun 21 '07 #7
The top one (I assume this is the one that doesn't work?) has no
Authorization header... this would be my first guess (although you
have set credentials...)

I was mainly looking for cookies and other form variables, but there
don't appear to be any in either ;-(

Marc

Jun 21 '07 #8
On Jun 21, 11:54 am, Marc Gravell <marc.grav...@g mail.comwrote:
The top one (I assume this is the one that doesn't work?) has no
Authorization header... this would be my first guess (although you
have set credentials...)

I was mainly looking for cookies and other form variables, but there
don't appear to be any in either ;-(

Marc
ya its really confusing

Jun 21 '07 #9
On Jun 21, 2:16 pm, shantanu <shantanuse...@ gmail.comwrote:
On Jun 21, 11:54 am, Marc Gravell <marc.grav...@g mail.comwrote:
The top one (I assume this is the one that doesn't work?) has no
Authorization header... this would be my first guess (although you
have set credentials...)
I was mainly looking for cookies and other form variables, but there
don't appear to be any in either ;-(
Marc

ya its really confusing
Hi i got a stack trace related to uploading the data
HTTP/1.1 401 Authorization Required

Date: Fri, 22 Jun 2007 03:19:27 GMT

Server: Apache/2.0.49 (Unix) mod_perl/1.99_13 Perl/v5.8.4 PHP/4.3.7
DAV/2 mod_ssl/2.0.49 OpenSSL/0.9.7d

WWW-Authenticate: Basic realm="Corporat e Internet Login "

Content-Length: 564

Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorizati on Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr />
<address>Apac he/2.0.49 (Unix) mod_perl/1.99_13 Perl/v5.8.4 PHP/4.3.7
DAV/2 mod_ssl/2.0.49 OpenSSL/0.9.7d Server at aww.ngn.bel.alc atel.be
Port 80</address>
</body></html>

but i am already using the code
WebClient client = new WebClient();
client.Headers. Add("Authorizat ion","Basic
"+Convert.ToBas e64String(Encod ing.ASCII.GetBy tes("user:pass" )));

client.Credenti als = netCred;
client.Headers. Add("PreAuthent icate","true");
client.Headers. Add("Content-Type","applicat ion/x-www-form-
urlencoded");
client.UploadFi le("http://aww.ngn.bel.alc atel.be/prp/cgi-bin/
secure/ImportForm.cgi? PL=L36051&root= AL","POST",@"C: \PRP
\PRPTemp.txt");

regards
shantanu

Jun 22 '07 #10

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

Similar topics

4
9708
by: Shawn Mesiatowsky | last post by:
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:...
5
103516
by: John Lee | last post by:
Hi, I have a simple web page that allow file to be uploaded, the upload page looks like the following: <form method="post" name="upload" enctype="multipart/form-data" action="processupload.aspx"> <input type=checkbox name="chkOverride" value="1"> <input type=file name="filename"> <input type=submit value="Upload Data File"...
0
1272
by: Kannan | last post by:
Hello, I was trying to upload a local file on a client machine to a sharepoint folder using the WebClient object. This method is present in a client side DLL. I need to upload the document using NTLM authentication. The method does not report any errors but the document does not appear in the folder. Here are the the two code snippets...
3
2418
by: Brian | last post by:
Hi, I've been trying to find a way to upload file to another site that is not using IIS. The site that I want to upload file to has a simple php script to receive file uploaded through standard http post with a file upload. However, how do I upload file to the site using asp.net? thanks Brian
5
737
by: Neo | last post by:
Hello, I am receiving a file as a binary stream from a C++ Client Application. >From the application, the file is being sent as a "Multipart/form-data". I want to receive this file on the server, for which i am using Request.Inputstream and reading it into a byte array. This is not working as it is coupling the binary content with some...
0
362
by: shantanu | last post by:
Hi i am trying to upload a txt file thru this code, but its not updating the data. is this code fine. Or can anybody please suggest me some other meathod to do the same. its urgent please help regards shantanu WebClient client = new WebClient();
5
3656
by: shantanu | last post by:
Hi i am trying to upload a txt file thru this code, but its not updating the data. is this code fine. Or can anybody please suggest me some other meathod to do the same. its urgent please help regards shantanu
21
34358
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready...
3
4289
by: =?Utf-8?B?dmFzaW1v?= | last post by:
Have the following code: wkLocalPath = "C:\A\1.jpg" wkServerPath = "http://servername/dirname/1.jpg" wcClient.Credentials = New NetworkCredential("UID", "PW") wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath) File exists on C. Dir exist on server (ASPNET user and Admin user have full rights) (tried both) Created virtual for Dirname...
0
7665
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...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6255
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...
1
5484
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...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
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
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.