title: How to debug a file upload?
body: <p>I'm trying to upload a PDF file to a website using Hot Banana's content management system using a Python script.  I've successfully logged into the site and can log out, but I can't seem to get file uploads to work.  </p>
  
  <p>The file upload is part of a large complicated web form that submits the form data and PDF file though a POST.  Using Firefox along with the Firebug and Tamper Data extensions I took a peek at what the browser was sending in the POST and where it was going.  I believe I mimicked the data the browser was sending in the code, but I'm still having trouble.  </p>
  
  <p>I'm importing cookielib to handle cookies, poster to encode the PDF, and urllib and urllib2 to build the request and send it to the URL.  </p>
  
  <p>Is it possible that registering the poster openers is clobbering the cookie processor openers?  Am I doing this completely wrong?</p>
  
  <hr>
  
  <p>Edit: What's a good way to debug the process?  At the moment, I'm just dumping out the urllib2 response to a text file and examining the output to see if it matches what I get when I do a file upload manually.  </p>
  
  <p>Edit 2: Chris Lively suggested I post the error I'm getting.  The response from urllib2 doesn't generate an exception, but just returns:</p>
  
  <pre><code>&lt;script&gt;
      if (parent != window) { 
          parent.document.location.reload(); 
      } else { 
          parent.document.location = 'login.cfm'; 
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>I'll keep at it.  </p>