Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2

register_openers()
fileToUpload = {'files[]': open('/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
C
[{"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...
Posted
Updated 8-Sep-13 2:36am
v2
Comments
pittip 8-Sep-13 12:45pm    
I know I am a newbie here but I request people here to assist me with my question. I have already tried a lot to solve it but have not tasted success yet. Please, please... help me!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900