#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    3
    Rep Power
    0

    Cool Http file upload (Post)


    Does anyone know how to upload a file and form data
    to a server?

    What i want to do is allow a user to upload a file and form data
    to my php script so i can process it. So of course FTP would be
    no good.

    I can do this with the XMLHTTP control but it does not thread and
    it pretty lame. Surely you can do it with winsock or Inet

    Any ideas?

    Source code would be greatly appreciated.

    Comments on this post

    • Gran Roguismo agrees
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Just a stupid question from me, but why not just have the user access the php page through a browser?

    Another possible solution would be to use sockets but I have no code for you on that, the MSDN library might have some examples for you though.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    3
    Rep Power
    0

    re: Http File uload (Post)


    Sorry forgot to mention, i have a VB program that the user uses and then they submit the info to the server. (a file and form fields)

    Here is the URL for the XMLHTTP method
    http://www.planetsourcecode.com/vb/s...=6076&lngWId=1

    Comments on this post

    • Gran Roguismo agrees
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,595
    Rep Power
    4207
    Try using the Webbrowser control from Microsoft Internet Controls to do your stuff. That's what I usually use, with code something like this:
    Code:
       Dim bPostData() As Byte
       Dim sHeaders As String
    
       sPost = "foo=1&bar=test&quux=42"  ' Post data
       sHeaders = "Content-Type: application/x-www-form-urlencoded" & vbCrlf ' Add extra headers as needed
       ReDim bPostData(Len(sPost))
       bPost = StrConv(sData, vbFromUnicode)
       WebBrowser.Navigate sURL, 0, vbEmpty, bPostData, sHeaders
        (or)
       WebBrowser.Navigate2 sURL, 0, vbEmpty, bPostData, sHeaders
    If you want to use a GET method instead of POST, then simply remove the extra params from the call and use WebBrowser.Navigate sURL or WebBrowser.Navigate2 sURL instead. I just put the above code together off the top of my head and haven't checked it to see if it actually works, but the syntax should be pretty close.

    Hope this helps!
    Last edited by Scorpions4ever; October 26th, 2002 at 02:05 AM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    3
    Rep Power
    0
    That method only works with Text files.

    Klemens Schmid has some source on how to send a text file
    using that method.

    http://www.schmidks.de/files/HttpUpload2.zip

    It works great but i get a weird error every second time i send
    to the server.
    The error is this:

    Method Not Implemented
    --AaB03x to / not supported.
    Invalid method in request --AaB03x

    The server is running Apache 1.3.26 (a freebie server)

    Any ideas why it does this?

IMN logo majestic logo threadwatch logo seochat tools logo