rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: vbn on August 19, 2010, 08:06:24 AM

Title: Exec on button trigger
Post by: vbn on August 19, 2010, 08:06:24 AM
I wanted to have a button next to each file in last column which when clicked is supposed to call an exe with the full file path as argument.

In then [+file] section , I added following in last column :
<form><input type='submit' onClick="{.exec|C:\prog.exe|out=#temp.}"></form>

however, this seems to be getting called for each file that is being 'displayed' and not waiting for any clicks....can someone guide me to a proper way of doing this ... also page needs to refresh once exe is done
Title: Re: Exec on button trigger
Post by: TSG on August 19, 2010, 01:53:55 PM
It is a server side macro, not client side.

You would have to redirect to a 'virtual page' that executes the file you want, then redirects you back... or use AJAX for it to happen without page changing. It is a bit complex to explain... you seem to know the basics so here goes nothing, this will be untested but just a suggestion for how to manually do it.

Send the file name and the page you are on to a 'virtual page' in the HFS template:

Code: [Select]
Now for the 'virtual page', this is where it happens:

Code: [Select]
[application = application.html]

{.comment| Execute the file before sending the page and redirecting. .}

{.comment| Show some information and redirect. .}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<title>Run Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="REFRESH" content="2;url={.?location.}">
<script type="text/javascript">
// You can use this if meta wont work!
// window.location = "{.?location.}"
<h3>- Application <i>"prog.exe"</i> was executed, redirecting back to location <i>"{.?location.}"</i>...</h3>