Hello, I have some php code that writes to a text file (via file_put_contents) and I figured out I need to store that in the proper location using the storage path (HEPubStorageLocation). However now I want to link to that file on the page so the user can click and download that file - how can I link to the file with an a href style html link?
That’s possible thanks to HEScript: in the UserMain script of your project, copy/paste this:
// Used by savingfiles.php
procedure OpenFormText;
var
S: String;
begin
// a) Get the path to the folder where to save the file.
S := GetGlobalVar("HEPubStorageLocation", "");
if S = "" then exit;
// b) Append the filename as defined in scriptsaveform.php
S := IncludeTrailingBackslash(S) + "saveform1.txt";
// c) Launch the default editor
OpenFile(S, "", SW_SHOWNORMAL);
end;
And then in your HTML code:
<a class="btn btn-default" href="hescript://UserMain.OpenFormText">Open the text file now</a></p>