Image 使用python cgi检索html表单的上传图像 #/usr/bin/env蟒蛇3 导入cgi 导入操作系统 从http.cookies导入* 导入sqlite3 path='/var/www/html/bb.db' con=sqlite3.connect(路径) cur=con.cursor() form=cgi.FieldStorage() 打印(“内容类型:text/html\n\n”) 印刷品( """ 五星 用力咀嚼 吉百利 香脆玉米棒 """) a=form.getvalue('drop')) b=form.getvalue('预览') 如果以表格和a形式“提交”=无: 当前执行(“删除表格图像”) cur.execute(“创建表映像(img blob)”) cur.execute(“插入到表值(?),(codecs.encode(form.getvalue('preview'))) 打印(“”)
""") 我试图检索一个图像上传在html格式与python cgi。。。 但是这个代码不起作用,…请帮我解决这个代码。。 先谢谢你。。。 实际上,我在上面的表格中也使用了enctype…但是它没有用Image 使用python cgi检索html表单的上传图像 #/usr/bin/env蟒蛇3 导入cgi 导入操作系统 从http.cookies导入* 导入sqlite3 path='/var/www/html/bb.db' con=sqlite3.connect(路径) cur=con.cursor() form=cgi.FieldStorage() 打印(“内容类型:text/html\n\n”) 印刷品( """ 五星 用力咀嚼 吉百利 香脆玉米棒 """) a=form.getvalue('drop')) b=form.getvalue('预览') 如果以表格和a形式“提交”=无: 当前执行(“删除表格图像”) cur.execute(“创建表映像(img blob)”) cur.execute(“插入到表值(?),(codecs.encode(form.getvalue('preview'))) 打印(“”),image,Image,""") 我试图检索一个图像上传在html格式与python cgi。。。 但是这个代码不起作用,…请帮我解决这个代码。。 先谢谢你。。。 实际上,我在上面的表格中也使用了enctype…但是它没有用 #!/usr/bin/env python3 import cgi import os from http.cookies import* import sqlite3 path= '/var/www/html/bb.db' con=sqlite3.connect(path) cur=con.
#!/usr/bin/env python3
import cgi
import os
from http.cookies import*
import sqlite3
path= '/var/www/html/bb.db'
con=sqlite3.connect(path)
cur=con.cursor()
form=cgi.FieldStorage()
print("Content-Type:text/html\n\n")
print(
"""
<html>
<body>
<form enctype="multipart/form-data" method="get">
<select name="drop" >
<option>5star</option>
<option>Munch</option>
<option>cadbury</option>
<option>Kurkure</option>
</select>
<br>
<input type="file" name="preview" accept="image/*" >
<input type="submit" name="submit" value="submit">
</form>""")
a=form.getvalue('drop')
b=form.getvalue('preview')
if 'submit' in form and a!=None :
cur.execute("drop table images")
cur.execute("create table images(img blob)")
cur.execute("insert into table values(?)",(codecs.encode(form.getvalue('preview'))))
print("""
<p><img src=""")
cur.execute("select * from images")
data=cur.fetchall()
print(codecs.decode(i[0][0]))
print("""alt="hii" style="width:320px;height:320px;border:0;"></p>
</body>
</html>
""")