vl wrote:

I am stuck on trying to preview images that are uploaded from a html form.


<form method="POST" action="py_save_new_image" enctype="multipart/form-data">
<input type="file"  name="file">
<input type="submit" name="save" value="Upload">

When the form is submited it sends it to a python script that gets the image and sends it to another page to be previewed. Problem is, I receive and error that the image cannot be displayed.

My python script is below.
    REQUEST=context.REQUEST
    content_type=file.headers['Content-Type']
    if content_type.find('image')!=-1:
        context.REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpg')
        img = file.read()
print context.dtml_select_new_image(context, context.REQUEST, image=img)
        return printed
    else:
        return "error"

I load the image in a dtml method with:
<dtml-var image>
_______________________________________________

Vi,

Your kind of vague but one thing i'd change is:

 print context.dtml_select_new_image(context, context.REQUEST, image=img)
to
 return context.dtml_select_new_image(context, context.REQUEST, image=img)

David


_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to