Jim Gallacher
jpg at jgassociates.ca
Thu Sep 21 08:32:03 EDT 2006
sandip wrote: > Hi all, > Other day i was trying to build upload functionality in psp. I am > handling form(method: POST) submission in psp. > this form contain a hidden element and a element of type file for upload. > I observed certain things. When I use form['field'] to access value of > hidden form element,and in same code > if I use FieldStorage(req) to get the attributes of uploaded file. I > can't access file attributes. > > but if I use only FieldStorage to access all the elements of form, I > could access it. > > so why can't I use both form and FieldStorage in same code? The form you see in psp is actually a FieldStorage instance which is automatically created when the psp parse encounters mention of the form variable. FieldStorage may only be called once per request, as it consumes the request body. Wnen it is called a second time, there is nothing left to read. The usual solution is to store a reference to the form in your request object, and pass that around to any functions that need it. <% stuff = form['stuff'] req.form = form %> You'll then be able to access the form in code outside of the psp page. Jim
|