CGI Proplem displaying image
matthiasjanes
matthiasjanes at gmx.net
Tue May 11 02:37:30 EDT 2004
matthiasjanes at gmx.net (matthiasjanes) wrote in message news:<d588131f.0405090912.560b51db at posting.google.com>...
> >
> > Use sys.stdout for output in CGI scripts.
> > Escpecially with binary files.
> > Try this and see if the problem goes away
> >
> > #################
> > #my CGISRIPT: test.py
> >
> > #! /usr/bin/env python
> >
> > import sys
> > sys.stdout("Content-type: image/jpeg\n\n")
> >
> > filename="cgi-bin/dog.jpg"
> > img = open(filename, 'rb').read()
> > sys.stdout.write(img)
> >
> > ##################
> >
> > Remember Google is your friend
> > http://starship.python.net/crew/davem/cgifaq/faqw.cgi
> >
> > waldek
>
Maybe my question was not clear enough: It is for me not a problem to
print the Image to screen. (As I said in the beginning) if I use a
form with method='post'
example:
____THIS WORKS FINE AND DISPLAYS ON ONE PAGE THE IMAGE AND ONLY THE IMAGE_______
#################
#my CGISRIPT: test.py
#! /usr/bin/env python
print ("Content-type: image/jpeg");
print # End of headers!
filename="cgi-bin//dog.jpg"
infile = open(filename, 'rb')
doginmemory=infile.read()
print doginmemory
##################
#################
#my html page with the image tag
<html>
<head>
</head>
<body>
<form name="test" method="post" action="/cgi-bin/test.py" target="_blank">
<input type="submit" name="GO"> </form>
</body>
</html>
################
____THIS WORKS FINE AND DISPLAYS ON ONE PAGE THE IMAGE AND ONLY THE IMAGE_______
BUT What I want is that I display the image on an HTML page with text
together.
tables and .......
something like that
#################
#my html page with the image tag
<html>
<head>
</head>
<body>
Some Text
<img type="image" src="/cgi-bin/test.py" height="25" width="111">
some Text
</body>
</html>
################
A working example code - even very small one would be appreciated
Matthias Janes
More information about the Python-list
mailing list