[Product-Developers] File saving with PloneFormGen in MySQL

Andreas Jung lists at zopyx.com
Thu Nov 13 09:50:50 UTC 2008


On 13.11.2008 10:41 Uhr, bad_my84 wrote:
> The problem is that I don't know how I can add a file via the 'File field'
> into the database.
>
> With strings&  integers I use the 'ZSQL Method' with:
> INSERT INTO tabel VALUES(
>    <dtml-sqlvar voornaam type=string>,
>    <dtml-sqlvar achternaam type=string>
> )
>
> But what kind of type should I use for a file? Or isn't it that ease?

No idea about MySQL but a blob-ish type is likely the right choice.
You have to check your MySQL documentation how to insert binary data 
into a blob. This is not a Zope issue since Zope generates only the SQL
_you are writing_. If you upload a file you should be able to get hold 
of the binary data of the file through something like

binary_data = context.REQUEST['name-of-file-field'].read()

-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 316 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20081113/fef54d59/attachment.vcf>


More information about the Product-Developers mailing list