vb.net cgi uploading files

Discussion in 'Perl Misc' started by marfi95@yahoo.com, Nov 8, 2005.

  1. Guest

    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 8, 2005
    #1
    1. Advertising

  2. sonet Guest

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



    <> ???
    news: ???...
    > 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
    >
     
    sonet, Nov 8, 2005
    #2
    1. Advertising

  3. Guest

    I don't want something form based though because this will be executing
    behind the scenes in the background of the app.
     
    , Nov 8, 2005
    #3
  4. Guest

    I don't want something form based though because this will be executing
    behind the scenes in the background of the app.
     
    , Nov 8, 2005
    #4
  5. 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
     
    A. Sinan Unur, Nov 8, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dermoon
    Replies:
    0
    Views:
    516
    dermoon
    Oct 8, 2003
  2. D Borland

    Uploading files using CGI.pm

    D Borland, Sep 28, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    209
    Alan J. Flavell
    Sep 29, 2003
  3. darius

    maybe OT: uploading files w/ cgi

    darius, Jul 21, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    154
    darius
    Jul 21, 2004
  4. William

    Uploading 2 files with 1 CGI buffer

    William, Jan 9, 2006, in forum: Perl Misc
    Replies:
    10
    Views:
    372
    Gunnar Hjalmarsson
    Jan 10, 2006
  5. ccc31807

    CGI and temFileName -- uploading files

    ccc31807, Dec 8, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    262
    ccc31807
    Dec 8, 2011
Loading...

Share This Page