473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

CGI, FieldStorage and Filename

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 : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com

Jul 18 '05 #1
0 1670

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fred Murray | last post by:
Hi all, When uploading a file ("input type=file"), FieldStorage usually behaves correctly, but every once in a while (every couple days?), it will suddenly start causing internal server errors. ...
1
by: Ames Andreas (MPA/DF) | last post by:
Hi, sorry for following-up to myself. Some remarks: 1) Please excuse the bogus original message. I wrote it a minute before I knocked off work and I promise to never do so again :-) 2)...
1
by: Ames Andreas (MPA/DF) | last post by:
Hi, I'm currently using Zope 2.7.2-0 which in turn uses cgi.FieldStorage from Python 2.3.4. FieldStorage can either build a 'list' or a 'file' to represent a request. Unfortunately it...
4
by: Derek Basch | last post by:
Given this FieldStorage object: FieldStorage(None, None, ) I am trying to cgi.urlencode the FieldStorage object to POST to another cgi script. The documentation for urlencode,...
2
by: praba kar | last post by:
Dear All, I have doubt in python cgi script. I describe that doubt with below code import cgi form = cgi.FieldStorage() passwd = form.value print passwd But Now I want to assign some value to...
3
by: Chris Curvey | last post by:
I can't be the first person to want to do this, but I also can't seem to find a solution. (Perhaps my Google skills are poor today.) How can I emulate cgi.FieldStorage() for my unit tests so that...
0
by: John Salerno | last post by:
I'm trying to use a for loop with a FieldStorage object and I get the following error. Can you not treat it like a dictionary, or am I writing the for loop incorrectly? for item in form: print...
7
by: John Salerno | last post by:
If I want to get all the values that are entered into an HTML form and write them to a file, is there some way to handle them all at the same time, or must FieldStorage be indexed by each specific...
4
by: arorap | last post by:
I've mod_php installed with Apache 2.2. In one of my folders, I'm using the cgihandler as the PythonHandler as my target host runs python only as CGI. Here cgi.FieldStorage() doesn't seem to work....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.