In the routine that creates the file, I send something like this after the file is created:
Packet='<br><button type="button" name="Download" id="Download" value="Download" onclick="window.open(''' & 'download/' & CLIP(Loc:WebFolder) & '/' & CLIP(Loc:FileName) & ''',''_self'')">Download ' & CLIP(Loc:Description) & '</button>'
Packet=CLIP(Packet) & '</br>'
DO Sendpacket
I isolate the files by session number, so the path is web\download\sessionnumber\filename.ext. I do this to keep common names, and allow a person to see what files he/she created via a browse.
I also have a cleanup routine that deletes everything in the web\download folder (and subfolder) after two hours.
To ensure that the file is sent correctly, I add the following code in the WebHandler, ThisNetWorker._SendFile, before parent call
! unless otherwise specified, make the reply content type unknown to force download
IF Instring('download',LOWER(p_FileName),1,1) THEN
self.ReplyContentType='countops/download'
END
! force download of TTP files regardless of the location
IF Instring('.ttp',LOWER(p_FileName),1,1) THEN
self.ReplyContentType='countops/ttp'
END
! allow display of .csv files regardless of the location
IF Instring('.csv',LOWER(p_FileName),1,1) THEN
self.ReplyContentType='application/vnd.ms-excel'
END
When the user clicks on the button, the file is either displayed in the current window (it can be moved to a separate window by changing the _self to something else, or the download dialog box opens. Pretty cool.