title: How to get absolute path of the file selected as input file in python?
body: <p>I want the absolute path of the file selected as input file (from file browser in the form) using the python code below:</p>
  
  <pre><code> for attr, document in request.files.iteritems():
          orig_filename = document.filename
          print os.path.abspath(orig_filename)
          mhash = get_hash_for_doc(orig_filename)
  </code></pre>
  
  <p>This prints the path of current working directory along(where the python script is executing) with the 'orig_filename' appended to it, which is the wrong path. I am using python 2.7, flask 0.12 under linux OS.</p>
  
  <p>The requirement is to find the hash value of the file before uploading it to the server to check deduplication. So I need to use the algorithm by passing the file selected for hashing to another function as:</p>
  
  <pre><code>def get_hash_for_doc(orig_filename):
      mhash = None
      hash = sha1()#md5()
      with open(mfile, "rb") as f:
          for chunk in iter(lambda: f.read(128 * hash.block_size), b""):
              hash.update(chunk)
      mhash = hash.hexdigest()
  
      return mhash
  </code></pre>
  
  <p>In this function I want to read file from absolute path of the orig_filename before uploading. Avoided all other code checks here.</p>