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