473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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.Credentials = netCred;
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/
ImportForm.cgi","POST",@"C:\PRP\PRPTemp.txt");

Jun 20 '07 #1
12 2039
Hi,

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

"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.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.Credentials = netCred;
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/
ImportForm.cgi","POST",@"C:\PRP\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.googlegr oups.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.Credentials = netCred;
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/secure/
ImportForm.cgi","POST",@"C:\PRP\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...@gmail.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...@gmail.comwrote:
Exactly:http://www.fiddlertool.com/Fiddler/version.asp
orhttp://www.fiddler2.com/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.alcatel.be

HTTP/1.1 100 Continue

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

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

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

number.name.content.original.content.approved.cont ent.planned.contentdeleted.original.contentdeleted .approved.contentdeleted.planned.contentchange.ori ginal.contentchange.approved.contentchange.planned .defectsdoc.original.defectsdoc.approved.defectsdo c.planned.defectscode.original.defectscode.approve d.defectscode.planned.defectstest.original.defects test.approved.defectstest.planned.defectsval.origi nal.defectsval.approved.defectsval.planned.defects fieldsw.original.defectsfieldsw.approved.defectsfi eldsw.planned.effort.original.effort.approved.effo rt.planned.effortdr1dr5.original.effortdr1dr5.appr oved.effortdr1dr5.planned.defectsfielddr5.original .defectsfielddr5.approved.defectsfielddr5.planned. nrcustomers.original.nrcustomers.approved.nrcustom ers.planned.salesvalue.original.salesvalue.approve d.salesvalue.planned.margin.original.margin.approv ed.margin.planned.dr0p.original.dr0p.approved.dr0p .planned.dr0p.status.dr1.original.dr1.approved.dr1 .planned.dr1.status.dr3.original.dr3.approved.dr3. planned.dr3.status.dr4.original.dr4.approved.dr4.p lanned.dr4.status.dr5.original.dr5.approved.dr5.pl anned.dr5.status.dr6.original.dr6.approved.dr6.pla nned.dr6.status.dr0.original.dr0.approved.dr0.plan ned.dr0.status.dr2.original.dr2.approved.dr2.plann ed.dr2.status.ci.original.ci.approved.ci.planned.c i.status.obr.original.obr.approved.obr.planned.obr .status.releasetype.location.locationlead.pl.

9YZ-00490-
AAAA.TestProject.................................. .......................
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.alcatel.be

Content-Length: 2155

Connection: Keep-Alive

Cache-Control: no-cache

Authorization: Basic c2hhbnRhbnUgc2VuOnN1bm55IzAwMw==

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

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

Content-Type: text/plain

number.name.content.original.content.approved.cont ent.planned.contentdeleted.original.contentdeleted .approved.contentdeleted.planned.contentchange.ori ginal.contentchange.approved.contentchange.planned .defectsdoc.original.defectsdoc.approved.defectsdo c.planned.defectscode.original.defectscode.approve d.defectscode.planned.defectstest.original.defects test.approved.defectstest.planned.defectsval.origi nal.defectsval.approved.defectsval.planned.defects fieldsw.original.defectsfieldsw.approved.defectsfi eldsw.planned.effort.original.effort.approved.effo rt.planned.effortdr1dr5.original.effortdr1dr5.appr oved.effortdr1dr5.planned.defectsfielddr5.original .defectsfielddr5.approved.defectsfielddr5.planned. nrcustomers.original.nrcustomers.approved.nrcustom ers.planned.salesvalue.original.salesvalue.approve d.salesvalue.planned.margin.original.margin.approv ed.margin.planned.dr0p.original.dr0p.approved.dr0p .planned.dr0p.status.dr1.original.dr1.approved.dr1 .planned.dr1.status.dr3.original.dr3.approved.dr3. planned.dr3.status.dr4.original.dr4.approved.dr4.p lanned.dr4.status.dr5.original.dr5.approved.dr5.pl anned.dr5.status.dr6.original.dr6.approved.dr6.pla nned.dr6.status.dr0.original.dr0.approved.dr0.plan ned.dr0.status.dr2.original.dr2.approved.dr2.plann ed.dr2.status.ci.original.ci.approved.ci.planned.c i.status.obr.original.obr.approved.obr.planned.obr .status.releasetype.location.locationlead.pl.

9YZ-00490-
AAAA.TestProject.................................. .......................
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...@gmail.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...@gmail.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="Corporate 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>Authorization 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>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 Server at aww.ngn.bel.alcatel.be
Port 80</address>
</body></html>

but i am already using the code
WebClient client = new WebClient();
client.Headers.Add("Authorization","Basic
"+Convert.ToBase64String(Encoding.ASCII.GetBytes(" user:pass")));

client.Credentials = netCred;
client.Headers.Add("PreAuthenticate","true");
client.Headers.Add("Content-Type","application/x-www-form-
urlencoded");
client.UploadFile("http://aww.ngn.bel.alcatel.be/prp/cgi-bin/
secure/ImportForm.cgi?PL=L36051&root=AL","POST",@"C:\PRP
\PRPTemp.txt");

regards
shantanu

Jun 22 '07 #10
Well, from your stack trace it doesn't seem to be using it... I'm
confused as to why you are doubling up on setting headers anyway:
surely .Credentials should manage the Authorization header (so why set
twice?) Likewise, the content-type of a file upload isn't application/
x-www-form-urlencoded, but multipart/form-data. You don't should
netCred being initialized, but I can't see why this isn't playing
ball...

Marc
Jun 22 '07 #11
On Jun 22, 12:01 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Well, from your stack trace it doesn't seem to be using it... I'm
confused as to why you are doubling up on setting headers anyway:
surely .Credentials should manage the Authorization header (so why set
twice?) Likewise, the content-type of a file upload isn't application/
x-www-form-urlencoded, but multipart/form-data. You don't should
netCred being initialized, but I can't see why this isn't playing
ball...

Marc
thanx marc
but any how is it possible that the server is not providing the
sufficient rights to upload the data in this way.I was reading in some
article that the portal should me deployed in a anonymous mode. Is it
true.??
regards
shantanu

Jun 22 '07 #12
On Jun 22, 2:10 pm, shantanu <shantanuse...@gmail.comwrote:
On Jun 22, 12:01 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Well, from your stack trace it doesn't seem to be using it... I'm
confused as to why you are doubling up on setting headers anyway:
surely .Credentials should manage the Authorization header (so why set
twice?) Likewise, the content-type of a file upload isn't application/
x-www-form-urlencoded, but multipart/form-data. You don't should
netCred being initialized, but I can't see why this isn't playing
ball...
Marc

thanx marc
but any how is it possible that the server is not providing the
sufficient rights to upload the data in this way.I was reading in some
article that the portal should me deployed in a anonymous mode. Is it
true.??
regardsshantanu
Hi
I am still waiting for the resolution kindly help
regards
shantanu

Jul 2 '07 #13

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

Similar topics

4
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...
5
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"...
0
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...
3
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...
5
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...
0
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 ...
5
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 ...
21
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...
3
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,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.