CGI, FieldStorage and Filename

N

Neil Benn

Hello,

I'm writing a simple cgi script and want to be able to access
the filename in a FieldStorage file instance. I have successfully
manmaged to access the file as a 'file-like object' by using the simple
code of :

objInFile = objForm['DataFile'].file

I can easily read through this data and get all the information out
as I need - sorted!! However, when I attempt to access the filename
attribute of this using :

print 'Content-Disposition: attachment; filename="' +
os.path.split(objForm['DataFile'].filename)[0] + '_reformatted.txt"'

I get None back for the filename. So I dumped the content of the
objForm['DataFile'] to stdout to see what it contains :

print objForm['DataFile']

I got back this :

FieldStorage('DataFile', 'MOAF_10-12_fin_2.txt',
'Project\tJob\tBarcode\tPlate set <blaahh, blaaahh, blahh>)

As you can see, when __str__ is called, the FieldStorage is
displaying the name of the client side file - so it knows what it is,
however when I call .filename on it, I get None. I don;t get what is
happening here - has anyone else seen this and/or knows what I'm doing
wrong?

If so then all and any help would be much appreciated.

Cheers,

Neil

--

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 46
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : (e-mail address removed)
Cenix Website : http://www.cenix-bioscience.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ConfigParser Keys 1
Plone FAQ 1
Python Twain 0
__eq__ on a dict 9
UML Tools 1
Oddity is shutil.copyfileobj 0
How to close a process in win32 0
epyDoc Questions 2

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top