"Pearson, Brian Edward (GEA, 056278)" wrote:
Can anyone provide some insight regarding the problem detailed below? Basically, I would like to add file attachment support to the ZDiscussion product. I have managed to do that successfully, however I cannot seem to create a URL to access the file such that it could be wrapped inside an HREF tag.
Any help would be greatly appreciated.
You'll probably need to create a function that sets the headers and mime types correctly, and returns the file data, then have the href point to that function. I've done this to return to the client a file that had been written to the filesystem. With a bit of modification, this should do what you need: # UNTESTED CODE based on working code... should work. def downloadAttachment(self, RESPONSE): RESPONSE.setHeader('content-type', 'application/octet-stream') RESPONSE.setHeader('Content-Disposition', 'attachment; filename=%s' % self.attachment_name); RESPONSE.write(self.attachment_data) What this should do is, when the user clicks the href that points to this function it will pop up a Save File dialog box with self.attachment_name as the filename (otherwise it will use the function name, which we don't really want). One caveat of doing it this way, is that it won't pop up the download window until _after_ the whole file is downloaded. Presumably, Netscape then simply renames the file in the cache to the desired filename. Anyway, this should point you in the right direction. -- Nick Garcia | ngarcia@codeit.com CodeIt Computing | http://codeit.com