由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - python + apache2 upload例子跑不了
相关主题
如何把python/scripts加到path里?这个画图的好像够 professional - sK1
html给php传文件的问题,求解!【问题】怎么知道apt-get都往Linux里写入了哪些文件
how do I remove this file???请推荐好的web hosting service,要求如下:
为什么linux有没有类似logmein的软件
Re: 有没有Linux版本的Serv-U? (转载)推荐ajaxterm
ubuntu怎么自动加载网卡?Python和gst-launch怎么写到一起?
请教Thinkpad的tp-smapi-module快速批量制作大量epub的办法
装了ubuntu 8.10,但是sudo apt-get insall不work我想买台 Linux Server, 请推荐. 谢谢
相关话题的讨论汇总
话题: file话题: usr话题: lib话题: module话题: line
进入Linux版参与讨论
1 (共1页)
h****g
发帖数: 772
1
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,)
1 (共1页)
进入Linux版参与讨论
相关主题
我想买台 Linux Server, 请推荐. 谢谢Re: 有没有Linux版本的Serv-U? (转载)
想在red hat Linux 下装 ubuntu 需要把硬盘上所有文件都给备份到其它盘里吗?ubuntu怎么自动加载网卡?
见鬼了。Apache 403 Forbidden请教Thinkpad的tp-smapi-module
PHP无法写文件的问题装了ubuntu 8.10,但是sudo apt-get insall不work
如何把python/scripts加到path里?这个画图的好像够 professional - sK1
html给php传文件的问题,求解!【问题】怎么知道apt-get都往Linux里写入了哪些文件
how do I remove this file???请推荐好的web hosting service,要求如下:
为什么linux有没有类似logmein的软件
相关话题的讨论汇总
话题: file话题: usr话题: lib话题: module话题: line