upload file with post params
Question: I want send file to url with some post params like "chat_id", "caption" and
file must be sended as 'photo' field-name.  
but I found only methods to send only POST params without file or sending only
file without POST params and custom file name param..  
This code send only `params` field, but I need also `files` field.

    
    
    from urllib import parse, request
    ...
    files={'photo': open('file.jpg','rb')}          
    params = parse.urlencode({'chat_id': chat_id, 'caption': 'test'})
    #headers = {"Content-type": "multipart/form-data"}      
    
    req = request.Request(url, params.encode('ascii'))
    response = request.urlopen(req)
    print(response.read())
    

Python 3.4.2


Answer: ok. I found solution.  
I install external lib [Requests: HTTP for
Humans](https://github.com/kennethreitz/requests).  
and now i'm using `requests`

    
    
    import requests
    ...
    url = 'https://api.telegram.org/bot'+self.token+'/sendPhoto' #'/sendmessage'
    print('request to '+url+' with params '+chat_id+' ' + text)     
    
    headers = {'Content-Type': 'multipart/form-data'}
    
    files = {'photo': open('file.jpg', 'rb')}
    params = {'chat_id': chat_id, 'caption': text}
    r = requests.post(url,  files=files, params=params)     
    print(r.text)   
    

