用python cgi读取文件

时间:2016-09-15 04:13:34

标签: python cgi cgi-bin

我的数据扩展名为.txt。我想阅读该文件,但他的错误结果result < cStringIO.StringO object at 0x7f5078d18068 >出了什么问题?

我的档案

Abedus
Accer
Chrome

HTML

<html>
    <body>
        <form enctype="multipart/form-data" action="http://localhost/cgi-bin/my.py" method="post">
            <p>File: <input type="file" name="filename"></p>
            <p><input type="submit" value="Upload"></p>
        </form>
    </body>
</html>

CGI Python

#!/usr/bin/python
import cgi, os
import cgitb; cgitb.enable()


form = cgi.FieldStorage()
data = form['filename'].file    

print "Content-Type: text/plain"
print ""
print "result %s" % data,

0 个答案:

没有答案