[mod_python] How to find a filename

Jim Gallacher jpg at jgassociates.ca
Sat Jan 20 11:01:04 EST 2007


export at hope.cz wrote:
> But how can I get the name of an uploaded file?
> I tried util.FieldStorage but I received the content of the file but not the 
> name of the file.

Jorey already gave you that answer.

filename = req.form['Picture'].filename

Jim


> Did I make a mistake somewhere?
> Lad.
> 
> 
> 
>>  If you are not using publisher or the psp handler you'll need to create
>>  a FieldStorage instance explicitly.
>>
>>  from mod_python import util
>>
>>  def handler(req):
>>      req.form = util.FieldStorage(req)
>>      ... and so on ...
>>
>>  Jim
>>
>>  export at hope.cz wrote:
>>  > Thank you for your reply but I do not use publisher.
>>  > Is there any other way?
>>  > Thank you for help
>>  > Lad
>>  >
>>  >
>>  >> export at hope.cz wrote:
>>  >>> I have a form through which users upload a file.
>>  >>>
>>  >>> <form method="post" action="test/mptest.py" enctype="multipart/form-data">
>>  >>>   <p><input type="file" name="Picture"> </p>
>>  >>> </form>
>>  >>> </body>
>>  >>>
>>  >>> Is it possible to find out the name of a file the user is being uploaded?
>>  >> If you are using Publisher, it will be available as:
>>  >>
>>  >>   req.form['Picture'].filename
>>  >>
>>  >
>>  >
>>  > _______________________________________________
>>  > Mod_python mailing list
>>  > Mod_python at modpython.org
>>  > http://mailman.modpython.org/mailman/listinfo/mod_python
>>  >
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list