April 16th, 2004, 11:27 PM
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
April 17th, 2004, 12:48 AM
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.