[python-win32] Sending a binary file from ASP

Emlyn Jones emlynj at gmail.com
Mon Apr 25 19:47:12 CEST 2005

I am trying to get an ASP script to download a file. The file arrives at the
correct size but is corrupted, what am I missing?
If I run the get_file function directly at the command prompt and save the
resulting data it is fine, so there must be something wrong with the way I send
the data from the browser?

If have this code in the asp page:
filename,data = get_file(file_path)
Response.AddHeader("content-disposition","attachment; filename=%s" %

the get_file function just does this:

def get_file(path):
   file = open(path,"rb")
   data = file.read()
   return os.path.split(path)[1],data

Any pointers will be greatfully recieved.


More information about the Python-win32 mailing list