[Zope-DB] Upload and download blobs to Mysql

Guido Gloor haslo.ch at gmail.com
Wed Jan 12 14:26:29 EST 2005


HI THERE (just so I shouted, too, in my answer)

The problem is not so much whether you use ZPT or DTML (I prefer
Python Scripts, but that's a programmer speaking), but that you
initialize the HTML-Form correctly. Image uploads have to be sent as
multipart form data with POST, otherwise you'll just receive the
filename.

Have a look here for the specifics...
http://www.bovik.org/device-upload.html
...or just use this basic functionality (with the appropriate action,
pointing to where you plan to process the data):

<form name="imageform" method="post" action="" enctype="multipart/form-data">
<input type="text" name="title">
<input type="file" name="imagefile">
<input type="submit" name="ok" value="OK"> 

You'll then have the values in your request.

When you get the data back from the database, be sure to set the
header correctly. It has to be image/jpeg for JPG files and image/gif
for GIFs. I honestly don't know how you set the header in ZPT and
DTML, in a Python Script it would be:

RESPONSE.setHeader('Content-Type', 'image/jpeg')

If you don't do that, the browser will interpret the image file as
text and just display garbage.

Hope this helps,
Cheers, Guido

On Wed, 12 Jan 2005 14:36:01 +0000 (GMT), RI-WU <umicah at yahoo.com> wrote:
> I want to upload photos and text to mysql 4.0.21 using
> zope 2.7.3 with page templates . I am building a site
> and I want the user to have the opurtunity to upload
> his news and photos .Are there any ideas, I am new I m
> using zpt .Is dtml a better way to do this???
> PLEEASSSE HEELP
> 
> 
> ___________________________________________________________
> ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
> _______________________________________________
> Zope-DB mailing list
> Zope-DB at zope.org
> http://mail.zope.org/mailman/listinfo/zope-db
> 


-- 
http://www.haslo.ch/


More information about the Zope-DB mailing list