Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initdir for input type="file" 1

Status
Not open for further replies.

iqof188

IS-IT--Management
Nov 9, 2000
228
GB
Hi all, I am working on a web-application, where users can pick a file with the HTML element <input type=&quot;file&quot;>. I want the dir G:\documents to be the initial dir (i.e. users must start browsing in this directory). I know in Visual Basic you can specify an initdir, but this doesn't seem to work with VBscript. Has anyone any idea how to do the trick? Thanx. <webguru>iqof188</webguru>
 
I can show you a way but it's not tested on Netscape.
Code:
<html>
<head>
<object id = &quot;cdl1&quot; CLASSID = &quot;Clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB&quot;>
<param name = &quot;InitDir&quot; value = &quot;C:\&quot;>
<param name = &quot;Filter&quot; value = &quot;Text Files (*.txt)|*.txt&quot;>
Error Loading Common Dialog!
</object>
<input type = &quot;text&quot; name = &quot;txtFile&quot; />
<script language = &quot;VBScript&quot;>
sub cdl()
cdl1.showopen
txtFile.value = cdl1.filename
end sub
</script>

<input type = &quot;button&quot; value = &quot;Browse ...&quot; onClick=&quot;cdl&quot; />

</head>
 
Thanks for your answer Caf, but it doesn't work on my machine (I am using IE5.0). I get the error message: &quot;Object doesn't support this property or method: 'cdl1.showopen'. Does this mean that the object is not installed on IIS4.0? Thanks for your help! <webguru>iqof188</webguru>
 
Hi

I don't understand why it doesn't work but try this alternative

<html>
<head>
<input type = &quot;text&quot; name = &quot;txtFile&quot; />
<script language = &quot;VBScript&quot;>
sub cdl()
dim cdl1
set cdl1 = createobject(&quot;MSComDlg.CommonDialog&quot;)
cdl1.showopen
txtFile.value = cdl1.filename
end sub
</script>

<input type = &quot;button&quot; value = &quot;Browse ...&quot; onClick=&quot;cdl&quot; />

</head>

BTW I tested this in IIS 4 & 5 IE4/5/5.5

caf

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top