Hey I want to insert a file from my "normal" file system into the ZODB database. I have collected the path from a form-field "file". The file that needs inserting must be placed in a certain folder inside Zope, and gets a title that I base upon a certain number. How can I - using DTML - insert this file? Can anyone supply me (fast, this is quite urgent...) with a few lines of code explaining this? Thanx!!!!! Maarten Demont maarten.demont@cronos.be Zope-Newbie
Hello Demont! a) If I understand you correctly, you want to upload a file from the client's file system to the server's ZODB as a new "file" object. Use: <dtml-call "folderobjectofyourchoice.manage_addFile('id_of_your_choice', file)"> (Make sure you had enctype="multipart/form-data" set in your form tag) This call will set the new file object's title to the filename by default. You have said that you want to set the _title_, but didn't mention the new object's id. If you specify keyword arguments, you can set everything by hand: <dtml-call "folderofyourchoice.manage_addFile(title='title of your choice', file=file, id='the_order_of_keyword_arguments_is_irrelevant')"> b) Please do not post on both "zope@zope.org" AND "zope-dev@zope.org" (see generated footer in mail) c) zope-dev is meant to be a mailing list for the development OF Zope, not WITH Zope. zope@zope.org would have been the appropriate place for posting. See http://www.zope.org/Resources/MailingLists d) Your question was definitely a FAQ. The Mailing List Archives are a very good place to start looking for an answer. Actually, I got more answers from there than from anyone personally! You can search them at NIP: http://zope.nipltd.com/public/lists.html Hope this helps, Danny On Wednesday 28 November 2001 21:29, Demont Maarten wrote:
Hey
I want to insert a file from my "normal" file system into the ZODB database. I have collected the path from a form-field "file". The file that needs inserting must be placed in a certain folder inside Zope, and gets a title that I base upon a certain number.
How can I - using DTML - insert this file?
Can anyone supply me (fast, this is quite urgent...) with a few lines of code explaining this?
Thanx!!!!!
Maarten Demont maarten.demont@cronos.be Zope-Newbie
---------------------------------------- Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1" Content-Transfer-Encoding: quoted-printable Content-Description: ----------------------------------------
demont, please do not cross-post your messages to more than one mailing list and please do not send HTML-formatted mail to the list. if the file that you want to get is supposed to be read from the filesystem of the machine your zope is running on without being uploaded by someone using a "file" form field then you cannot do this directly in DTML. Zope cannot touch the file system on the machine it runs on in arbitrary locations, think about the security risk. what you would need to do is write an external method and pass it the file path. external methods have less security restrictions and you could read the file that way and instantiate an object in the ZODB from it. jens On Wednesday, November 28, 2001, at 03:29 , Demont Maarten wrote:
Hey
I want to insert a file from my “normal” file system into the ZODB database. I have collected the path from a form-field “file”.
The file that needs inserting must be placed in a certain folder inside Zope, and gets a title that I base upon a certain number.
How can I – using DTML – insert this file?
Can anyone supply me (fast, this is quite urgent…) with a few lines of code explaining this?
Thanx!!!!!
Maarten Demont
maarten.demont@cronos.be
Zope-Newbie
I want to insert a file from my normal file system into the ZODB database. I have collected the path from a form-field file. The file that needs inserting must be placed in a certain folder inside Zope, and gets a title that I base upon a certain number.
How can I using DTML insert this file?
participants (4)
-
Danny William Adair -
Demont Maarten -
Jens Vagelpohl -
Steve Drees