Results 1 to 8 of 8

Thread: uploading a file to web server using internet transffer control and cgi script

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    7

    Post

    I am building a client application in vb. This application is for uploading a file to a web server. The server has a CGI application which uploads the file from the client. The vb application on the client(which i am suppose to make) communicates with the CGI application on server through http, providing it the path of the file(on the client) to be uploaded. Along with file path it also has to send the comment given by user which is also processed by the CGI application.
    I am using internet transfer control in my application. I am using "execute" command and in it i am using "post" method.
    codes are as follows

    strurl="http:// url / directory /upldfl.cgi"
    strformdata = "upfile = c:\dir1\testfile5 note=xyz"
    Inet1.Execute strurl, "POST", strformdata, "Content-Type : multipart/form-data enctype : multipart/form-data"

    Error from the server is "Boundary not provided: probably a bug in your server at ./cgi-lib.pl line 417." But this client application has already been made in HTML and is properly communicating with the cgi application at server end. Thus i dont think there is any problem with cgi script. You can see this application in HTML by going to http://edi.delhi.nic.in/~valsa/fu.html

    I have doubts whether
    1. strformdata = "upfile = c:\dir1\testfile5 note=xyz" is correct. Do we specify multiple parameters(upfile,note) by puting a space in between.

    2. Inet1.Execute strurl, "POST", strformdata, "Content-Type :multipart/form-data enctype : multipart/form-data" & vbcrlf
    Are different parameters(content-type,enctype) in header field seperated by a space.

    3. Is the content-type used correct.


    I tried very hard to find some material and examples on it but could not. The examples provided dont pass multiple parameter and no example for file uploading is provided using internet control tool and http.

    Please help me and if possible inform me where i can get this information.

  2. #2
    Guest

    Post

    I think your string needs to be like:
    "variable1=value1&variable2=value2"
    Notice the ampersand "&".
    So try:
    strformdata = "upfile=c:\dir1\testfile5&note=xyz"
    However, if you need spaces, they are replaced with plus "+" symbols. Notice the URL for this post: http://www.vb-world.net/cgi-bin/post...net+transffer+ control+and+cgi+script+

  3. #3
    Guest

    Post

    Your specific StringVariable got posted badly due to some built in commands for this post program. Take a look at my example, I'm sure you'll see what I mean.

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Posts
    7

    Post

    Thanks for replying,VirtuallyVB.

    I tried the following code
    strurl="http://edi.delhi.nic.in/valsa-cgi-bin/upldfl.cgi"
    strformdata="upfile=c:\trainees\testfile5&note=xyz"
    Inet1.Execute strurl, "post", strformdata

    but it gives error "content-type not specified"
    On giving content-type:

    Inet1.Execute strurl, "Post", strformdata, "content-type:multipart/form-data"

    It gives error:
    "Boundary not provided: probably a bug in your server"

    But i dont think there is a bug in server as the same code in CGI at server is being run properly by a code in HTML.

    I got the relevent information from MSDN library(Internet transffer control and execute method) and RFC 1867 (which is Form based file upload in HTML)

  5. #5
    Guest

    Post

    Welcome to the wonderfull world of Microsoft!

    I had an intermittent problem with the Inet control which was never resolved and I lost interest. Maybe you can get help from the following post: http://www.vb-world.net/ubb/Forum4/HTML/000210.html

  6. #6
    New Member
    Join Date
    Jun 1999
    Location
    33104 ocean ridge
    Posts
    6

    Post

    "I tried the following code
    strurl="http://edi.delhi.nic.in/valsa-cgi-bin/upldfl.cgi"
    strformdata="upfile=c:\trainees\testfile5¬e=xyz"
    Inet1.Execute strurl, "post", strformdata"

    Well I dont know much about the Inet control but I do know a little about CGI. From the above the cgi prgram is located here: http://edi.delhi.nic.in/valsa-cgi-bin/upldfl.cgi
    and the 2 variables you want the Program to parse are:
    1 - upfile=c:\trainees\testfile5¬
    2 - e=xyz
    And i see that you are trying to use the post method. Well I am pretty sure that you do not necessarily have to use the "POST" method for your cgi program to recognize what you want it to do. Try posting it like this with "GET":
    "http://edi.delhi.nic.in/valsa-cgi-bin/upldfl.cgi?upfile=c:\trainees\testfile5¬&e=xyz"

    Hope this helps and works!

    TJP

  7. #7
    New Member
    Join Date
    Jun 1999
    Location
    33104 ocean ridge
    Posts
    6

    Post

    Oops I just read your first question above..
    and it looks liek the second parameter is note=xyz so use this instead. http://edi.delhi.nic.in/valsa-cgi-bi...file5&note=xyz

  8. #8
    New Member
    Join Date
    Feb 2000
    Location
    Linkoping, SWEDEN
    Posts
    10

    Post Did you solve this?

    Im trying to do the exact same thing!
    Did you manage to do it??? Please help me if
    you did...

    I have read the file to binary, but when I post it I only get like the 7 first bytes?
    The code looks like this:
    (ReadFile reads the txtfile.Caption to binary)
    I think the problem is at "boundary" or "content-length" or something...

    oHttp.setRequestHeader "Content-Type", "multipart/form-data; boundary=--------------AaB03x"
    strBody = _
    "--------------AaB03x" & vbCrLf & _
    "Content-Disposition: form-data;name=""p_filename""; filename=""" & txtfile.Caption & """" & vbCrLf & _
    "Content-Type: application/vnd.ms-word" & vbCrLf & vbCrLf & _
    ReadFile(txtfile.Caption) & vbCrLf & _
    "--------------AaB03x"



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width