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) Thanks __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail
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) -----------------------------------------------------------------------
How can I know all the attributes related to filePath ?? --- "SER.RI-TIC-Alexis Roda" <alexis.roda@urv.net> wrote:
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)
-----------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
john blair wrote:
How can I know all the attributes related to filePath ??
RTSL. I suggest you look in lib/python/OFS/dtml and find the file that handles the adding of File obejcts through the ZMI... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
john blair wrote:
How can I know all the attributes related to filePath ??
take a look at source code lib/python/ZPublisher/HTTPRequest.py, search for class FileUpload, __init__ method you can write an external method that returns the dir() of an object ... use some documentation product, like DocFinderEverywhere ... HTH -- //// (@ @) ----------------------------oOO----(_)----OOo-------------------------- <> Ojo por ojo y el mundo acabara ciego /\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) -----------------------------------------------------------------------
participants (4)
-
Andreas Pakulat -
Chris Withers -
john blair -
SER.RI-TIC-Alexis Roda