1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Rep Power

    Getting the name of an uploaded file

    I need some help here, please..
    On the HTML form the user can upload a file and I want to read
    it's the file name and it's content on the server.
    The cgi.FieldStorage() returns something like:
    FieldStorage(None,None, [FieldStorage(arg1, arg2, arg3) ] )
    arg1 is the html element name (the file input element)
    arg2 is the name of the uploaded file
    arg 3 is the uploaded file's content.
    I can have access to arg1 and arg3 ( using key[].value)
    but I can't have access to the file name (arg2).
    Isn't there a simple built in function in the cgi module?! ( i didn't find any)
    Thank you very much
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Hull, UK
    Rep Power
    Havn't used CGI in a while since my own Net module handles everything the way i want it to - and very well - but i believe you use '.filename' or '.file' instead of the standard '.value' name. This should give you the full path of the file being uploaded, you then just have to get the filename from the path.

    programming language development: www.netytan.com Hula

IMN logo majestic logo threadwatch logo seochat tools logo