[Zope] Get mime type and filename without path in python

Dieter Maurer dieter at handshake.de
Fri Sep 17 16:43:44 EDT 2004


Patrick Ulmer wrote at 2004-9-17 09:43 +0200:
>I want to allow uploading files from my website and put it in a 
>database. My short script works:
>
>if myfile and myfile.filename != '':
>    container.dbUpdateFile (id=str (id_ds), myfile=myfile.read ())
>
>Now I want to put the mimetype in the database put how can I get the 
>mimetype?

There is a "guess_mimetype" (or similarly spelled) that does
this job for "OFS.Image". See there, how it is used.

You may need an External Method (or special security declaration
see "PythonScripts.README")
to overcome security restrictions.

-- 
Dieter


More information about the Zope mailing list