按照网络的教程用Python编写CGI上传文件,一直出现500,怎么回事?
html文件:
文件上传
.py文件
#!/usr/bin/python
# -*- coding:utf-8 -*-
import cgi, os
import cgitb; cgitb.enable()
# 获取文件名
f = cgi.FiledStorage().getvalue('filename')
# 检测文件是否上传
if f is not None:
# 设置文件路径
fn = os.path.basename(f.filename.replace("","/"))
open('/tmp/' + fn,'wb').write(f.file.read())
message = '文件 "' + fn + '" 上传成功'
else:
message = "文件没有上传"
print """
Content-Type:text/html
文件上传
%s
""" % (message,)
错误信息:
[Thu May 11 10:24:46.697197 2017] [http:error] [pid 8254] [client 127.0.0.1:58072] AH02429: Response header name '
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你不觉得你的错误信息里面的url长的很奇怪么,在你的浏览器打开看看。
不是应该studycgi.com么
错误信息不是比较明确么: Response header name '<!--' contains invalid characters