Just wanted to share this. Basically wanted a way to server up ANY file and have the user save/open it.
Basically, you have to send a different header than what NT sends.
Create a new web page, and set the header to other. Uncheck Send Header.
Then put the code below under Processed Code, Priority 500 (must be 500, before calling the header routine).
! set our content type
lCT = 'application/x-download'
! send custom header
packet = 'HTTP/1.0 200 OK<13,10>' & |
'Content-Type: ' & CLIP(lCT) & '<13,10>' & |
'Content-Disposition: attachment; filename=' & CLIP(lFN) & '<13,10>' & |
'<13,10>'
do sendpacket
! send it
p_web._SendFile(lFileName,NET:NoHeader)
! return without footer
return
Obviously, you have to setup lFilename as the full filename to download - remember security issues too. (I get the filename using GetValue, validate the login and location of the file is ok).
lCT is the content type - set to x-download
lFN is the filename only
FYI - The 'content-disposition' header tag is what causes the dialog box to show up on the browser, allowing the user to save or open the file.
You could also modify the content type and remove the disposition based on the extension of the file.
You might want to add other header tags to deal with caching, dates, etc - but this appears to work for me at this time the way it is.
BRUCE: It would be VERY COOL to setup utility functions to change/add header tags before sending the header out. Take a look at the header() function within PHP.
Also - unchecking the "Send HTTP Header" doesn't work - that's why the code above has to be at priority 500.
Hope this helps to other people....
Cheers!