vb.net cgi uploading files

M

marfi95

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
 
S

sonet

You can find that how to implement uploading files in RFC-1867 and does not
using the CGI Module!
 
M

marfi95

I don't want something form based though because this will be executing
behind the scenes in the background of the app.
 
M

marfi95

I don't want something form based though because this will be executing
behind the scenes in the background of the app.
 
A

A. Sinan Unur

(e-mail address removed) wrote in @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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top