franse
asked on
Browse for a directory instead of browse for files
Hello,
Normaly in ASP with a browse button you open a browse window and you browse for files. But can this work for directory's as well?
I like to catch a directory path and write it to a DB.
Points go to someone who has the code for this functionality.
Thanks,
frans
Normaly in ASP with a browse button you open a browse window and you browse for files. But can this work for directory's as well?
I like to catch a directory path and write it to a DB.
Points go to someone who has the code for this functionality.
Thanks,
frans
try this, this is example from MSDN uses shell object.
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnGetMyPathJ()
{
var oShell = new ActiveXObject("Shell.Appli cation");
var oFolder = new Object;
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
var oFolderItem = new Object;
oFolderItem = oFolder.Items().Item();
document.all.item("myPath" ).innerTex t = oFolderItem.Path;
}
-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnGetMyPathJ()
{
var oShell = new ActiveXObject("Shell.Appli
var oFolder = new Object;
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
var oFolderItem = new Object;
oFolderItem = oFolder.Items().Item();
document.all.item("myPath"
}
-->
</SCRIPT>
ASKER
Sorry VincentPuglia your code does not work.
Hello appari,
I can't get your code working either,
But can you please deliver the code I need in ASP to call for it?
like VincentPuglia did.
Thanks,
franse
Hello appari,
I can't get your code working either,
But can you please deliver the code I need in ASP to call for it?
like VincentPuglia did.
Thanks,
franse
ok try this
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnGetMyPathJ()
{
var oShell = new ActiveXObject("Shell.Appli cation");
var oFolder = new Object;
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
var oFolderItem = new Object;
oFolderItem = oFolder.Items().Item();
document.all.item("myPath" ).innerTex t = oFolderItem.Path;
}
-->
</SCRIPT>
</head>
<body>
<form name="a">
<input type="TEXT" name='myPath'>
<input type="button" value="Browse" onclick='fnGetMyPathJ()'>
</form>
</body>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnGetMyPathJ()
{
var oShell = new ActiveXObject("Shell.Appli
var oFolder = new Object;
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
var oFolderItem = new Object;
oFolderItem = oFolder.Items().Item();
document.all.item("myPath"
}
-->
</SCRIPT>
</head>
<body>
<form name="a">
<input type="TEXT" name='myPath'>
<input type="button" value="Browse" onclick='fnGetMyPathJ()'>
</form>
</body>
ASKER
Appari,
The script returns an error:
Permission denied in line 9 character 5
Line 9 =
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
thanks,
franse
The script returns an error:
Permission denied in line 9 character 5
Line 9 =
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
thanks,
franse
Hi franse,
I just uploaded it to: http://members.aol.com/grassblad/clients/getDir.html
It browses my computer, allows me to pick a file, and then by hitting the button, puts the non-filename portion of the path in the second text box.
The only thing I added was an alert
What doesn't work?
Vinny
I just uploaded it to: http://members.aol.com/grassblad/clients/getDir.html
It browses my computer, allows me to pick a file, and then by hitting the button, puts the non-filename portion of the path in the second text box.
The only thing I added was an alert
What doesn't work?
Vinny
ASKER
Sorry VincentPuglia,
Now I understand your sollution.
But it is not what I was looking for. The sollution should also work for directories that contain only subdirectories. Correct me if I am wrong, but I think this will not work in those cases.
Thanks,
franse
Now I understand your sollution.
But it is not what I was looking for. The sollution should also work for directories that contain only subdirectories. Correct me if I am wrong, but I think this will not work in those cases.
Thanks,
franse
Hi franse,
You're correct. you're looking for an IE-only solution?
You're correct. you're looking for an IE-only solution?
ASKER
yes
The sollution will be used in an intranet application so I am shure the clients all work with IE5.5 or higher.
The sollution will be used in an intranet application so I am shure the clients all work with IE5.5 or higher.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
VincentPuglia,
This script results in the same error:
Permission denied in line 9 character 3
Line 9 =
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
thanks,
franse
This script results in the same error:
Permission denied in line 9 character 3
Line 9 =
oFolder = oShell.BrowseForFolder(0, "Choose a folder", 0);
thanks,
franse
you do not have permissions?
what folder are you trying to get to?
what folder are you trying to get to?
what is your environment? browser, etc.etc.
ASKER
1) that is a secure site -- and it didn't even put up the browse dialog when I tried.
2) you probably need read permissions
2) you probably need read permissions
ASKER
No the site has a front door but the back door is open.
But ok an other profider and other site with no protection:
http://www32.brinkster.com/monnik/test.asp
same error
But ok an other profider and other site with no protection:
http://www32.brinkster.com/monnik/test.asp
same error
Hi franse,
Sorry to say but there seems to be some reason for it not to work on the web. I uploaded my example here:
http://members.aol.com/grassblad/clients/getDir.html
as well as a different M$ example that uses the shell.app... here:
http://members.aol.com/grassblad/clients/getFolderItem.html
while both work locally, they both fail ungracefully (without error messages) on the net. All of this means to me that something on the web is preventing the activexobject from executing as it should.
Vinny
Sorry to say but there seems to be some reason for it not to work on the web. I uploaded my example here:
http://members.aol.com/grassblad/clients/getDir.html
as well as a different M$ example that uses the shell.app... here:
http://members.aol.com/grassblad/clients/getFolderItem.html
while both work locally, they both fail ungracefully (without error messages) on the net. All of this means to me that something on the web is preventing the activexobject from executing as it should.
Vinny
ASKER
OK your right it works localy. And for now this will do.
If one of the experts knows how to get this functionality working on an INTRAnet sollution I am willing to give some points for that answer too. Let's say 200 points
one question ramains how to devide the points?
The points to devide are 125 in this Javascript question.
200 points in the ASP section
20 points in the VB section
Thanks,
franse
If one of the experts knows how to get this functionality working on an INTRAnet sollution I am willing to give some points for that answer too. Let's say 200 points
one question ramains how to devide the points?
The points to devide are 125 in this Javascript question.
200 points in the ASP section
20 points in the VB section
Thanks,
franse
Hi franse,
I presume you mean you have asked the same question in 3 places and that at least in one of them no one responded. You can have the points refunded, refunded and increased, or have the 'user' post in the empty question and then award the points there.
It really depends on how much the 'points' mean to you. (They buy me neither cigarettes nor espresso, so I don't really care.) If you look at the 'experts' rank and/or point total before looking at his/her solution, then hand out as many points as you want.
Vinny
I presume you mean you have asked the same question in 3 places and that at least in one of them no one responded. You can have the points refunded, refunded and increased, or have the 'user' post in the empty question and then award the points there.
It really depends on how much the 'points' mean to you. (They buy me neither cigarettes nor espresso, so I don't really care.) If you look at the 'experts' rank and/or point total before looking at his/her solution, then hand out as many points as you want.
Vinny
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: VincentPuglia {http:#9658692}
Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jAy
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: VincentPuglia {http:#9658692}
Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jAy
EE Cleanup Volunteer
since I tested this on my machine and not the web, you may have to switch ("\\") to ("/")
function doit(formObj)
{
x = formObj.b.value.lastIndexO
formObj.c.value = formObj.b.value.substring(
}
//-->
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<input type="text" name='c'>
<input type="button" onclick='doit(this.form)'>
</form>