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
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