NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: terryd on July 29, 2014, 09:43:52 AM
-
I have a button in a browse which on click displays an associated file. How do I ensure that the user has the choice of save or open. Certain file types (e.g. text and .msg) are opened directly in the browser and in the case of msg are not displayed correctly. If it's not possible to always give the choice I would rather force save and let them open afterwards.
-
set the ContentDisposition header. As in;
p_web.HeaderDetails.ContentDisposition = 'attachment; filename="whatever'''
I don't know the exact architecture of your setup, but I'm guessing the easiest way is to add a parameter to the button URL and then in WebHandler, in _SendFile, set the header if that parameter exists. If your button does something other than a URL then let me know what.
cheers
Bruce
-
If I add this code into the _SendFile procedure in the webhandler before the Parent Call my view problem is solved.
SaveFileName = st.FileNameOnly(p_FileName)
p_web.HeaderDetails.ContentDisposition = 'attachment; filename= ' & SaveFileName
SaveFileName is a local variable in the Webhandler
I need to control which procedures in the application will run this code so if I do something like
IF p_web.GSV('AllowThis')
SaveFileName = st.FileNameOnly(p_FileName)
p_web.HeaderDetails.ContentDisposition = 'attachment; filename= ' & SaveFileName
END
this should allow me to restrict operation of this code
How should I do this?
In the button I use to view the file I use a local variable which has the location of the file which I put into the URL field in the OnClick tab for the button. The parameter field is disabled so what would I do to set the AllowThis Sessionvalue.
I do need to do this because file upload needs to ignore this code otherwise it keeps on asking to save the uploaded file when I click save.
-
can you add the parameter to the button URL?
-
Hi Kevin the button URL is l:FilePath, a local variable that points to the location of the file. What would the URL be to set, say, p_web.SSV('AllowThis','Yes')
-
I had a look at my app and I do exactly the same as you. Technically you could add a parameter to the variable but you would need to trap that in the sendfile embed and do some processing.
You might be able to take a different approach by calling a procedure like ServeDocument and the passing your parameters including the file name.
-
Thank Kevin.
I don't have a problem with doing some trapping in the sendfile embed, One of the beauties of StringTheory. So what should my url look like?
-
this is just my theory...
so with your variable that is the filename, append a parameter either as part of the Variable or on the URL field in the template
eg l:var = clip(your filename) & '?myuniqueparameter=' & whatever
But really what you are doing is creating something unique about the filenames from that procedure so you can trap it and do some processing. Calling it a parameter could be confusing. maybe the following is better:
eg l:var = clip(your filename) & '^myuniqueparameter=' & whatever
-
I like;
eg l:var = clip(your filename) & '?myuniqueparameter=' & whatever
Terry, uou should be using
p_web.GetValue('myuniqueparameter')
not p_web.GetSessionValue
in your test.
The session value will always be true, whereas you are trying to make some decision for just this thread.
-
Thanks guys. I'll work on it over the weekend