Follow the tutorial on the Internet and use Python to write CGI to upload files, but 500 keeps appearing. What's going on?
html file:
文件上传
.py file
#!/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,)
error message:
[Thu May 11 10:24:46.697197 2017] [http:error] [pid 8254] [client 127.0.0.1:58072] AH02429: Response header name '