[Zope] Attach File

SER.RI-TIC-Alexis Roda alexis.roda at urv.net
Thu Feb 24 03:39:05 EST 2005


john blair wrote:
> Hi
> I want to upload a file.The user provides the file
> title and file path.
> Say this is the form 
> <input type="text" name="fileTitle">
> <input type="file" name="filePath">
> Now I want the name of the file to be the id of the
> file in zope.Say the user attaches the file
> /var/test.doc.Then id of the file should be test.doc
> 
> add_method =
> context.manage_addProduct['OFSP'].manage_addFile
> add_method(??,filePath,fileTitle)

Probably the filename is not a good choice for the id. IDs must comform
the the regexp [a-zA-Z0-9-_~,.$\(\)# ]+, file names shouldn't

anyway, IIRC what you get when you upload a file is a
ZPublisher.HTTPRequest.FileUpload instance wich has a filename attribute
  (filePath.filename in your example,) wich stores the full path of the
file on the client side




HTH
-- 
                                    ////
                                   (@ @)
----------------------------oOO----(_)----OOo--------------------------
<>               Ojo por ojo y el mundo acabara ciego
/\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
-----------------------------------------------------------------------




More information about the Zope mailing list