Discussion:
HTA And File Input
(too old to reply)
Randy Webb
2004-12-26 23:14:42 UTC
Permalink
With a normal HTML file, I know the security issues prohibit setting the
value of an input type="file". Is there any setting that I can change
that will allow me to set/change the value of a type="file" input in an
HTA? This application is local to me so I have full access to change any
settings I need to change. WinXP SP2 with IE6.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Randy Webb
2005-01-09 01:27:54 UTC
Permalink
With a normal HTML file, I know the security issues prohibit setting the
value of an input type="file". Is there any setting that I can change
that will allow me to set/change the value of a type="file" input in an
HTA? Or maybe an ActiveXObject?

This application is local to me so I have full access to change any
settings I need to change. WinXP SP2 with IE6.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
benben
2005-01-09 12:49:04 UTC
Permalink
Are you trying to submit/upload a file to a server from your HTA?

ben
Post by Randy Webb
With a normal HTML file, I know the security issues prohibit setting the
value of an input type="file". Is there any setting that I can change
that will allow me to set/change the value of a type="file" input in an
HTA? Or maybe an ActiveXObject?
This application is local to me so I have full access to change any
settings I need to change. WinXP SP2 with IE6.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Randy Webb
2005-01-09 17:35:04 UTC
Permalink
Post by benben
Post by Randy Webb
With a normal HTML file, I know the security issues prohibit setting the
value of an input type="file". Is there any setting that I can change
that will allow me to set/change the value of a type="file" input in an
HTA? Or maybe an ActiveXObject?
This application is local to me so I have full access to change any
settings I need to change. WinXP SP2 with IE6.
Are you trying to submit/upload a file to a server from your HTA?
No.

I have an alarm clock/timer application that has an array of times that
it checks for. For each time, a different sound can be associated with
it. All of that data is contained in a JS array:

alarmTime[0] = ['05','00','00','AM','fullPathToSound.wav'];
alarmTime[1] = ['06','00','00','AM','fullPathToSound.wav'];
alarmTime[2] = ['07','30','00','AM','fullPathToSound.wav'];
alarmTime[3] = ['08','00','00','AM','fullPathToSound.wav'];

and so on.

When I want to add a new one, I can simply go edit the JS Array and add
new ones. Thats simple for me. Not so simple for my 9 and 15 year old
daughters. So, I started on a second section of it that allows it to set
the times. When the setAlarm.hta is opened, it reads that .js file and
creates the inputs to show all the times they have chosen. They can edit
each, add more, and then save it.

What I have done for now is to have two inputs, one the File and one a
Text Input. When the File Input is changed, it updates the Text Input.
And the Text Input's value is set when the page is created. It works but
its messy (to me). I was hoping there was some way in the relaxed
Security Environment of an HTA that would allow the setting of the File
Input. Even if it means I have to create the entire page, then after the
page is loaded go back and update the File Inputs.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Michael Harris (MVP)
2005-01-09 21:55:46 UTC
Permalink
.... I was hoping there was some way in the relaxed
Security Environment of an HTA that would allow the setting of the
File Input. Even if it means I have to create the entire page, then
after the page is loaded go back and update the File Inputs.
From an HTA running on an XP box you can useUserAccounts.CommonDialog ...

Here's a WSH hosted example from the TechNet script center.

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Scripts"
intResult = objDialog.ShowOpen

If intResult = 0 Then
Wscript.Quit
Else
Wscript.Echo objDialog.FileName
End If
--
Michael Harris
Microsoft MVP Scripting
Randy Webb
2005-01-10 03:19:42 UTC
Permalink
Post by Michael Harris (MVP)
.... I was hoping there was some way in the relaxed
Security Environment of an HTA that would allow the setting of the
File Input. Even if it means I have to create the entire page, then
after the page is loaded go back and update the File Inputs.
From an HTA running on an XP box you can useUserAccounts.CommonDialog ...
Here's a WSH hosted example from the TechNet script center.
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Scripts"
intResult = objDialog.ShowOpen
If intResult = 0 Then
Wscript.Quit
Else
Wscript.Echo objDialog.FileName
End If
Thanks Michael. But unfortunately, that's not the part of the File Input
I was wanting to set. I want to set the value of an Input Type="file"
form Input:

<input type="file" name="myInput" value="Default Value">

But it won't display the Default Value. I want/need to be able to set
it's value programatically.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
benben
2005-01-10 03:55:45 UTC
Permalink
It just happens that the <input type="file"> cannot be set programmatically,
even in an HTA. So you have to user something else such as the common dialog
box Michael suggested.

ben
Post by Randy Webb
Post by Michael Harris (MVP)
.... I was hoping there was some way in the relaxed
Security Environment of an HTA that would allow the setting of the
File Input. Even if it means I have to create the entire page, then
after the page is loaded go back and update the File Inputs.
From an HTA running on an XP box you can useUserAccounts.CommonDialog ...
Here's a WSH hosted example from the TechNet script center.
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Scripts"
intResult = objDialog.ShowOpen
If intResult = 0 Then
Wscript.Quit
Else
Wscript.Echo objDialog.FileName
End If
Thanks Michael. But unfortunately, that's not the part of the File Input
I was wanting to set. I want to set the value of an Input Type="file"
<input type="file" name="myInput" value="Default Value">
But it won't display the Default Value. I want/need to be able to set
it's value programatically.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Randy Webb
2005-01-10 04:12:31 UTC
Permalink
Post by benben
It just happens that the <input type="file"> cannot be set programmatically,
even in an HTA. So you have to user something else such as the common dialog
box Michael suggested.
I actually mis-read Michael's post and it's implications on what I was
trying to do. Instead of trying to set a type="file" input, his code
allows me to create my own "Browse" button and set the value of a
regular input. Does precisely what I wanted to do.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Randy Webb
2005-01-10 04:16:50 UTC
Permalink
Post by Randy Webb
Post by Michael Harris (MVP)
.... I was hoping there was some way in the relaxed
Security Environment of an HTA that would allow the setting of the
File Input. Even if it means I have to create the entire page, then
after the page is loaded go back and update the File Inputs.
From an HTA running on an XP box you can useUserAccounts.CommonDialog ...
Here's a WSH hosted example from the TechNet script center.
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Scripts"
intResult = objDialog.ShowOpen
If intResult = 0 Then
Wscript.Quit
Else
Wscript.Echo objDialog.FileName
End If
Thanks Michael. But unfortunately, that's not the part of the File Input
I was wanting to set. I want to set the value of an Input Type="file"
<input type="file" name="myInput" value="Default Value">
But it won't display the Default Value. I want/need to be able to set
it's value programatically.
I have it now :) Instead of trying to set the value, I use my own
CommonDialog to let the file be chosen, then set a normal text input's
value.

Thank you.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Michael Harris (MVP)
2005-01-10 05:16:49 UTC
Permalink
Post by Randy Webb
Thanks Michael. But unfortunately, that's not the part of the File
Input I was wanting to set. I want to set the value of an Input
<input type="file" name="myInput" value="Default Value">
But it won't display the Default Value. I want/need to be able to set
it's value programatically.
But you won't be able to... The rules for input type=file is the same for
an HTA as it is for ordinary IE hosted HTML.
--
Michael Harris
Microsoft MVP Scripting
Loading...