Solved

Sending images to Browser with VB 4.0

Posted on 1998-11-04
7
170 Views
Last Modified: 2013-12-25
I made a cgi with the module 'cgivb4.bas' from Kevin O'Brien and i send the date (text) with the procedure 'Send'.

If i would send a image (gif) i need to use de procedure 'SendB'??. What mean 'Content-type image/jpeg'??.
0
Comment
Question by:arapahoe
  • 4
  • 3
7 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829408
The content-type is a so-called http header and it is used so the browser can identify the data being sent.
To send image data you need to use the binary version of send as I expect SendB is.

'Content-type image/jpeg' means that the data you sned is a jpg file but you would want
'Content-type image/gif'
instead.

make sure that there is an empty line after
'Content-type image/gif'

and here the image data should be sent.

Michel
0
 

Author Comment

by:arapahoe
ID: 1829409
I try with this code and not work:

------------------------------------------------------------
    While Not BDD_Result.EOF
        Send ("<tr>")
        Send ("    <td width=20%>")
        Send "Content-type: image/gif" & vbCrLf
        fdIN = FreeFile
        Open PathImatges & BDD_Result!numero_cliente & ".gif"
              For Binary As fdIN
        ContingutImatge = InputB(LOF(fdIN), fdIN)
        Close fdIN
        SendB (ContingutImatge)
        Send "Content-type: text/html" & vbCrLf
        Send ("    </td>")
        Send ("</tr>")
        BDD_Result.MoveNext
    Wend
    Send ("</table>")
-----------------------------------------------------


It's correct???
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829410
Not at all!

HTML is text and can contain an image link. That image link points to an image file or in your case should point at an image producing cgi, passing the image name to the cgi:

  While Not BDD_Result.EOF
               Send ("<tr>")
               Send ("    <td width=20%>")
               Send ("    <IMG SRC=""othervbprogram?" & BDD_Result!numero_cliente & ".gif" & """)
               Send ("    </td>")
               Send ("</tr>")
               BDD_Result.MoveNext
           Wend
           Send ("</table>")

Please fix the quotes yourself, I am not a VB programmer.

Then have an othervbprogram that does an
    Send "Content-type: image/gif" & vbCrLf
               fdIN = FreeFile
               Open PathImatges & parameter
                     For Binary As fdIN
               ContingutImatge = InputB(LOF(fdIN), fdIN)
               Close fdIN
               SendB (ContingutImatge)

where parameter is what was after the ? in the image link...

Hope this helps

Michel
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:arapahoe
ID: 1829411
OK!!.

I think this solution its ok.

Thanks
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1829412
Glad to hear it, can I post it again as an answer?

Michel


0
 

Author Comment

by:arapahoe
ID: 1829413
Yes, and thanks again
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 1829414
Thank,

 While Not BDD_Result.EOF
                      Send ("<tr>")
                      Send ("    <td width=20%>")
                      Send ("    <IMG SRC=""othervbprogram?" & BDD_Result!numero_cliente & ".gif" & """)
                      Send ("    </td>")
                      Send ("</tr>")
                      BDD_Result.MoveNext
                  Wend
                  Send ("</table>")

       Please fix the quotes yourself, I am not a VB programmer.

       Then have an othervbprogram that does an
           Send "Content-type: image/gif" & vbCrLf
                      fdIN = FreeFile
                      Open PathImatges & parameter
                            For Binary As fdIN
                      ContingutImatge = InputB(LOF(fdIN), fdIN)
                      Close fdIN
                      SendB (ContingutImatge)

       where parameter is what was after the ? in the image link...

Michel
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question