add a File type via a form
Hi, I have a very simple "index_html". It s a form in which I ask for an "Id" <form action="addFile" method="post"> <div>Id</div> <input type="text" name="id" size="40" /> <input type="submit" name="submit" value="Add File" /> </form> what I want is when the visitor fill the form and then submit it, a "File" object is created inside the same container. I added a Python script named "addFile" in the same container, and tried some things... but always failed. How to create a "File" then? Thank you. PS: I know the danger if an anonymous can do such things as creating an object into a container, but it's just for learnig prupose at the moment.
----- Original Message ----- From: "Mihamina Rakotomandimby" <mihamina.rakotomandimby@etu.univ-orleans.fr> To: <Zope@zope.org> Sent: Monday, December 18, 2006 7:13 AM Subject: [Zope] add a File type via a form
Hi, I have a very simple "index_html". It s a form in which I ask for an "Id"
<form action="addFile" method="post"> <div>Id</div> <input type="text" name="id" size="40" /> <input type="submit" name="submit" value="Add File" /> </form>
what I want is when the visitor fill the form and then submit it, a "File" object is created inside the same container.
I added a Python script named "addFile" in the same container, and tried some things... but always failed.
How to create a "File" then?
If you are trying to get your 'visitor' to upload a file (?), then couple of changes to your html: <form action="addFile" method="post" enctype="multipart/form-data"> <input type="file" name="id" size="40" /> And, in your script file you should be using manage_addFile (google for details if you need them) If you are not trying to upload a file, then we need some more information as to what you are trying to accomplish. hth Jonathan
On Mon, 2006-12-18 at 08:42 -0500, Jonathan wrote:
If you are trying to get your 'visitor' to upload a file (?),
No. I want the visitor to fill a form, and then the values he filled the form with are stored un 1 File. 1 File per form filled.
If you are not trying to upload a file, then we need some more information as to what you are trying to accomplish.
So, each time a visitor fills a form, I firts need to create the File, then I will see later how to write into the File. But I almost found: I have to use manage_addfile. But I dont know, the "title" argument is not working properly: If I hardcode the "title" when calling manage_addfile, there is no problem. If I try to set it throuhg the form, the string goes into the body of the file instead of the "title" when the File is created...
----- Original Message ----- From: "Mihamina Rakotomandimby" <mihamina.rakotomandimby@etu.univ-orleans.fr> To: <Zope@zope.org> Sent: Monday, December 18, 2006 10:10 AM Subject: Re: [Zope] add a File type via a form
On Mon, 2006-12-18 at 08:42 -0500, Jonathan wrote:
If you are trying to get your 'visitor' to upload a file (?),
No. I want the visitor to fill a form, and then the values he filled the form with are stored un 1 File. 1 File per form filled.
If you are not trying to upload a file, then we need some more information as to what you are trying to accomplish.
So, each time a visitor fills a form, I firts need to create the File, then I will see later how to write into the File. But I almost found: I have to use manage_addfile. But I dont know, the "title" argument is not working properly: If I hardcode the "title" when calling manage_addfile, there is no problem. If I try to set it throuhg the form, the string goes into the body of the file instead of the "title" when the File is created...
If you have a simple html form like: <form action="ptst" method="post"> Enter File Name: <input type="text" name="fName" value="" size="20"><br> Enter File Title: <input type="text" name="fTitle" value="" size="20"><br> Enter File Type: <input type="text" name="fType" value="" size="20"><br><br> <input type="submit" value="Create File"> </form> And a simple python script ('ptst') with parameters "fName", "fType" and "fTitle" (note: script parameters match form field names) and contains something like: context.manage_addFile(id=fName, file=None, content_type=fType, title=fTitle) return 'Done' It should give you the basis for what you are trying to accomplish (if I understand the requirement correctly!) Jonathan
participants (2)
-
Jonathan -
Mihamina Rakotomandimby