I'm trying to write a script that will keep a count of the number of times a file is downloaded. So far, the script just takes the name of the required file, opens the file, and passes on its contents. It works fine, except for one annoying thing: When Netscape pops up the box requesting a file name for saving, the default filename seems to be constructed in a screwy way from parts of the URL. For instance, if the URL used to retrieve the file is download.py?file=download/akaroa2.6.1doc.tar.gz then the default filename that Netscape gives me is akaroa2.6.1doc.tar.py So, my question is, can I put anything in the headers of the response to give the browser a hint as to what name the file should be saved under? Or is there a better way of going about this whole counting business? This is the script I'm using: #!/usr/local/cosc/bin/python print "Content-Type: compressed/gzip" print import cgi, sys form = cgi.FieldStorage() path = form["file"].value f = open(path) sys.stdout.write(f.read()) f.close() -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4