By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,007 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,007 IT Pros & Developers. It's quick & easy.

vb.net cgi uploading files

P: n/a
Hi all,

I'm trying to do what I consider to be a fairly simple task, yet I'm
having a heck of a time getting it to work. I'm trying to upload a
file (without user intervention and a browser) from a vb.net client
(using webclient or httpwebrequest) to a webserver running a cgi script
to store it on the webserver.

I'm not familiar with perl/cgi very well and am really struggling with
it. I kind of got it to partially work with webclient object and using
uploadvalues by sending the data in namedata collection. However, I
was only able to send half the file (according to the messagebox)
before I started getting 408 request timeout errors. (I determined
this by just sending half the file in the string instead of the whole
file contents).

Any help at all would be great. here are some snippets of my basic
flow. It may not be exact, but you can get the feel.

in VB.net:

Dim myQueryStringCollection As New NameValueCollection

myQueryStringCollection.Add("file", "C:\LogFile")
myQueryStringCollection.Add("data", dataContents) - a string
containing the log file contents

myWebClient = New WebClient
myWebClient.Credentials = New NetworkCredential("", "")
httpresponsearray = myWebClient.UploadValues(txtDest.Text, "POST",
myQueryStringCollection)
MsgBox(Encoding.ASCII.GetString(httpresponsearray) ) 'show
results
in CGI: (very simple just to see if the script is receiving)

#!/usr/bin/perl -w

use CGI;

print "Content-type: text/html\n\n";
print "<html><body>";

$query = new CGI;

$filepath = $query->param ('file');
$dest = $query->param ('data');

$destfile = "C:\\uploads\test.txt";
print $dest, "<br>";
print "Your file ($destfile) has been successfully uploaded.","<br>";
print "</body></html>";

Any ideas what is wrong, are there better ways to do this ? If someone
has already done this and has some code they would share, that would be
SOOOOO great.

Mark

Nov 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You can find that how to implement uploading files in RFC-1867 and does not
using the CGI Module!

<ma*****@yahoo.com> ???
news:11*********************@g14g2000cwa.googlegro ups.com ???...
Hi all,

I'm trying to do what I consider to be a fairly simple task, yet I'm
having a heck of a time getting it to work. I'm trying to upload a
file (without user intervention and a browser) from a vb.net client
(using webclient or httpwebrequest) to a webserver running a cgi script
to store it on the webserver.

I'm not familiar with perl/cgi very well and am really struggling with
it. I kind of got it to partially work with webclient object and using
uploadvalues by sending the data in namedata collection. However, I
was only able to send half the file (according to the messagebox)
before I started getting 408 request timeout errors. (I determined
this by just sending half the file in the string instead of the whole
file contents).

Any help at all would be great. here are some snippets of my basic
flow. It may not be exact, but you can get the feel.

in VB.net:

Dim myQueryStringCollection As New NameValueCollection

myQueryStringCollection.Add("file", "C:\LogFile")
myQueryStringCollection.Add("data", dataContents) - a string
containing the log file contents

myWebClient = New WebClient
myWebClient.Credentials = New NetworkCredential("", "")
httpresponsearray = myWebClient.UploadValues(txtDest.Text, "POST",
myQueryStringCollection)
MsgBox(Encoding.ASCII.GetString(httpresponsearray) ) 'show
results
in CGI: (very simple just to see if the script is receiving)

#!/usr/bin/perl -w

use CGI;

print "Content-type: text/html\n\n";
print "<html><body>";

$query = new CGI;

$filepath = $query->param ('file');
$dest = $query->param ('data');

$destfile = "C:\\uploads\test.txt";
print $dest, "<br>";
print "Your file ($destfile) has been successfully uploaded.","<br>";
print "</body></html>";

Any ideas what is wrong, are there better ways to do this ? If someone
has already done this and has some code they would share, that would be
SOOOOO great.

Mark

Nov 23 '05 #2

P: n/a
I don't want something form based though because this will be executing
behind the scenes in the background of the app.

Nov 23 '05 #3

P: n/a
I don't want something form based though because this will be executing
behind the scenes in the background of the app.

Nov 23 '05 #4

P: n/a
ma*****@yahoo.com wrote in news:1131466692.289424.79440
@g14g2000cwa.googlegroups.com:
I'm not familiar with perl/cgi very well and am really struggling with
There is no such monster called perl/cgi. There is the Perl language and
the CGI protocol. Failing to partition the problem leads to wasted time.
#!/usr/bin/perl -w

use CGI;

print "Content-type: text/html\n\n";
print "<html><body>";

$query = new CGI;

$filepath = $query->param ('file');
$dest = $query->param ('data');

$destfile = "C:\\uploads\test.txt";
print $dest, "<br>";
print "Your file ($destfile) has been successfully uploaded.","<br>";
print "</body></html>";

Any ideas what is wrong, are there better ways to do this ? If someone
has already done this and has some code they would share, that would be
SOOOOO great.


Yes, someone has already done it. The correct ways to submit the upload, as
well as to process it are explained in the CGI.pm documentation.

Sinan
Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.