POST发送数据:
python
# encoding:utf-8 import requests from StringIO import StringIO img = open('test.jpg').read() img = StringIO(img) files = {'img': img} baseUrl = r'http://localhost:8080/test' requests.post(baseUrl, files = files)
在web.py里
python
import web from PIL import Image urls = ('/test', 'Test') class Test: def GET(self): pass def POST(self): data = web.input() # 如何用PIL打开获取来的StringIO? img = Image.open(StringIO(data.img)) # 报错
线谢谢各位了。
upload.py
main.py (儲存圖片到指定路徑並另存縮圖)