Results 1 to 2 of 2

Thread: [RESOLVEDish] Sending pictures from picturebox through http

  1. #1

    Thread Starter
    Hyperactive Member half flung pie's Avatar
    Join Date
    Jun 2005
    Location
    South Carolina, USA
    Posts
    317

    Resolved [RESOLVEDish] Sending pictures from picturebox through http

    I've made a VB program that is run on my Apache server as a CGI program
    I'm using the following code, written by Kevin O' Brien, to send text via http
    Code:
    Sub Send(s As String)
    '======================
    ' Send output to STDOUT
    '======================
    Dim lBytesWritten As Long
    
    s = s & vbCrLf
    WriteFile hStdOut, s, Len(s), lBytesWritten, ByVal 0&
    End Sub
    and I would use
    Code:
    Send "<html><head>"
    elsewhere in my project. This all works perfectly fine.
    There is an alternate Send sub,
    Code:
    Sub SendB(s As String)
    '============================================
    ' Send output to STDOUT without vbCrLf.
    ' Use when sending binary data. For example,
    ' images sent with "Content-type image/jpeg".
    '============================================
    Dim lBytesWritten As Long
    
    WriteFile hStdOut, s, Len(s), lBytesWritten, ByVal 0&
    End Sub
    How do I get my picture data into binary data so I can pass it to this sub? And also, would I use
    Code:
    Send "Content-type: image/jpeg"
    SendB Form1.Picture.Image
    Sorry this is such a loaded question, but it's been plaguing me for days.
    -Dallas
    Last edited by half flung pie; May 22nd, 2007 at 09:16 AM.

    Base 2
    Fcnncu"Nqxgu"Lguug##

  2. #2

    Thread Starter
    Hyperactive Member half flung pie's Avatar
    Join Date
    Jun 2005
    Location
    South Carolina, USA
    Posts
    317

    Re: Sending pictures from picturebox through http

    Update to anyone reading this in the future. (ooo spooky...)
    Code:
     Send "Content-type: image/jpeg" & vbCrLf
     Dim fnum As Integer
     fnum = FreeFile
     Open JPEGFilePath For Binary As fnum
      SendB Input(LOF(fnum), #fnum)
     Close #fnum
    Works dandy. So I'll just have to save my picturebox to a jpeg, then send, I guess.

    Base 2
    Fcnncu"Nqxgu"Lguug##

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