Python上传图片/文件

import os
import requests

# 文件名称
file_path = '/Users/jopa/Pictures/123.jpeg'
file_name = os.path.basename(file_path)

url = "http://**.**.com/upload/uploadSingleFile"
file_data = {'file': (file_name, open(file_path, 'rb'), 'image/jpeg')}
headers = {
     "Cookie": "SESSION=d640c8a0-9845-43d5-8005-ae04b3596109",
}

r = requests.post(url,files=file_data,headers=headers).text
print(r)

赞 (0)

评论区

评论已关闭
回到顶部