[Problem with Python uploading files] When uploading files according to online tutorials, 500 errors keep appearing.
大家讲道理
大家讲道理 2017-05-18 10:49:26
0
2
863

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 '
    
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!