url = 'http://api-fotki.yandex.ru/api/users/' + login + '/photos/'
img = open(filename, 'rb')
result = requests.post(url,
files={'image': img},
headers=
{
"Authorization": "OAuth " + token,
"Accept": "application/json"
}
)
if you upload more then your server's post_max_size setting the input will be empty, hence a token miss-match
so if you have 2 upload input's in your form and your upload_max_filesize is 2G, your post_max_size needs to be at least 4G