Images not diplayed...

B

Blaktyger

Helllo,

I'm trying to set up a web page where users can upload their pictures.
I wrote a python script witch allows users to preview the pictures
posted to the database. Problem is that under Mozilla Firefox, the
images are not displayed.

This is the script I wrote:
#!/usr/bin/python2.3

print 'Content-Type: text/html\n\n'
import blakHtml, sys, cgi, urllib
sys.stderr = sys.stdout
prevSt=cgi.FieldStorage()


1 if not prevSt.has_key('nbOfPic'):
2 print 'blah blah!'
3 else:
4 nbOfPic2=prevSt['nbOfPic'].value

5prevPg=blakHtml.HTMLDocument()


6 header=prevPg.htmlHeader('Picture Preview')
7 beginTable=prevPg.tableTag()
8 p=0

9 nbOfLine=0
10 addLine=' '
11 for picLinked in range(int(nbOfPic2)):
12 p=p+1
13 exec("""if not prevSt.has_key('pin_nb_%s'):
14 pass
15 else:
16 addLine=addLine +'<img border="0" src="
'+prevSt['pin_nb_%s'].value+'" 17 width="204" height="152">
'+prevSt['pin_nb_%s'].value
18 nbOfLine=nbOfLine+1
19 if nbOfLine==5:
20 nbOfLine=0
21 addLine=addLine+'<br>' """)%(p,p,p)
22 print header+addLine+prevPg.htmlFooter()

line 6 generates the web page title
the loop check for non-null cgi values and creates the corresponding
<img> tag

Link to webpage http://pythonboard.homelinux.com/cgi-bin/howManyPics.py

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top