Redian新闻
>
python + apache2 upload例子跑不了
avatar
python + apache2 upload例子跑不了# Linux - Linux 操作系统
s*7
1
最近常吃素~~~家里没什么食材~~~~随便做了
终于用回自己的相机~~~
看得出我炒的是什么吗~~~~回头公布做法~~~~也许都不用讲做法啦~~~~超简单超快速的
avatar
n*1
2
我06年8月底的都非要等到7月份以后了吧
avatar
h*g
3
http://www.tutorialspoint.com/python/python_cgi_programming.htm 'filename'
系统是debian squeeze, python 2.6.6, apache2
错误信息如下
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537,
in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229,
in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128,
in _execute_target
result = object(arg)
File "/usr/lib/python2.6/dist-packages/mod_python/publisher.py", line 204,
in handler
module = page_cache[req]
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1059,
in __getitem__
return import_module(req.filename)
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 296,
in import_module
log, import_path)
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 680,
in import_module
execfile(file, module.__dict__)
File "/home/ghuang/www/cgi/t1.py", line 9, in
fileitem = form['filename']
File "/usr/lib/python2.6/cgi.py", line 541, in __getitem__
raise KeyError, key
KeyError: 'filename'
MODULE CACHE DETAILS
Accessed: Fri Oct 7 00:25:55 2011
Generation: 17


action="save_file.py" method="post">

File:






Here is the script save_file.py to handle file upload:
#!/usr/bin/python
import cgi, os
import cgitb; cgitb.enable()
form = cgi.FieldStorage()
# Get filename here.
fileitem = form['filename']
# Test if the file was uploaded
if fileitem.filename:
# strip leading path from file name to avoid
# directory traversal attacks
fn = os.path.basename(fileitem.filename)
open('/tmp/' + fn, 'wb').write(fileitem.file.read())
message = 'The file "' + fn + '" was uploaded successfully'

else:
message = 'No file was uploaded'

print """\
Content-Type: text/html\n


%s




""" % (message,)
avatar
F*t
4
你这不错了,FY11怎么都能排到
你4年多都等了,还差这几个月?
avatar
b*u
5
别哭啦,你快熬成婆啦。后面要哭的人多这那!
avatar
T*k
6
你还算好的呢!
avatar
D*O
7
俺排期8/7
avatar
T*r
8
办了. 就几个月了还在这里JJWW, 我们还有好几年的怎么办

【在 n**********1 的大作中提到】
: 我06年8月底的都非要等到7月份以后了吧
avatar
n*1
9
黎明前的黑暗最是难捱呀
avatar
m*e
10
这得握握手!我也使8/7/06!

【在 D****O 的大作中提到】
: 俺排期8/7
avatar
m*e
11
re这个,大实话!

【在 n**********1 的大作中提到】
: 黎明前的黑暗最是难捱呀
avatar
i*e
12
GX. 你几个月就要排到了, 比好多人好

【在 n**********1 的大作中提到】
: 我06年8月底的都非要等到7月份以后了吧
avatar
D*O
13
第二次握手!

【在 m*****e 的大作中提到】
: 这得握握手!我也使8/7/06!
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。