I am badly stuck up and I'm not able to proceed any further. Trust me, I have looked all over the web to get a CONCRETE solution but all in vain! I have an application where I need to upload a file and verify if it's uploaded. After I login to this application and reach the page where I have the button to select a file to be uploaded, here is my code:

from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2

fileToUpload = {'files[]'pen('/home/pinku/Desktop/Test_Upload.odt', 'rb')}
datagen, headers = multipart_encode(fileToUpload)
url = "(URL address blocked: See forum rules)"
request = urllib2.Request(url, datagen, headers)
print urllib2.urlopen(request).read()

The error I keep getting every single time is [{"error":true,"error_msg":"Authentication Failed"}]

I know I just need to simulate the actual file upload process which is nothing but an HTTP POST request to the server which also includes some authentication that I need to overcome.

My assumption is that may be cookies can help me in resolving this authentication issue but I am not sure and I do not know how to include it in my python code. Any sample code will be helpful. I request anyone reading this to help me.

Thanks anyways...