In addition to the other advice you have received, watch out for the filename containing the full path in platform specific formats (i.e. :: from Macs and \\ from Windows). Cliff Asad Habib wrote:
Hello. Is there a way to pass a variable for the id argument to manage_addFile? I want the user to be able to choose the id for a file that they wish to upload instead of hard-coding it in as a string literal.
I have tried the following code which is inside a Python script:
fileName = REQUEST.form['publicationsFile'] context.manage_addFile(id=fileName, file=fileName, title=' ', precondition=' ', content_type='application/pdf')
The error I get is as follows:
Error Type: Bad Request Error Value: The id "<ZPublisher.HTTPRequest.FileUpload instance at 0x46a0170>" contains characters illegal in URLs.
However, if I use a string literal, everything works fine. The following yields no errors but doesn't serve my purpose:
fileName = REQUEST.form['publicationsFile'] context.manage_addFile(id='fileName', file=fileName, title=' ', precondition=' ', content_type='application/pdf')
Also, if anyone knows of another method that could achieve the same purpose, please let me know. Any help would be greatly appreciated. Thanks.
- Asad
_______________________________________________ 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 )