Fwd: [Zope-DB] Upload and download blobs to Mysql

Guido Gloor haslo.ch at gmail.com
Wed Jan 12 14:31:20 EST 2005


Sorry, I forgot. Just in case you don't know that as well, which
sounds reasonable, you being new to all this and all. After you get
the data in the request, you'll have to add it to the database, using
a Z SQL method. In the database, you'll have to have a blob field, any
other field will be way too small for holding all the data of an
image.

Maybe somebody with more experience in ZPT and DTML can help you with
the specifics of how exactly you put the data into the database - I'm
fairly a newbie myself, I've started with Zope less than half a year
ago, and I mainly use Python Scripts...

Cheers, and I hope I didn't forget anything else,
Guido

---------- Forwarded message ----------
From: Guido Gloor <haslo.ch at gmail.com>
Date: Wed, 12 Jan 2005 20:26:29 +0100
Subject: Re: [Zope-DB] Upload and download blobs to Mysql
To: zope-db at zope.org


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/


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


More information about the Zope-DB mailing list