January 30th, 2003, 02:16 AM
|
#1 (permalink)
| | Member
Join Date: Aug 2002 Location: Downunder
Posts: 432
|
I'm trying to store the full network path of a file in a shared directory
network into a database, so that other users using the same database can
call up this document from anywhere in the network.
for example
Mapped location on local system: L:\Subdirectory\Disaster.doc
Network location: \\NetworkFileServer\ITDATA\Disaster.doc
I have a form where the user browses the local file system to 'upload'. My aim is to get this location and map it to the corresponding network path location. Then store the network path in the database.
in this case, if a user decides to upload 'Disaster.doc' from his/her L: drive, the network location of the file i.e. "\\NetworkFileServer\ITDATA\Disaster.doc" is stored in the database.
How do I get this corresponding network location?
I'll be using JSP/Javascript, but dont hesitate to present solutions using anything else. |
| |
January 31st, 2003, 12:47 AM
|
#2 (permalink)
| | Member
Join Date: Aug 2002 Location: Downunder
Posts: 432
|
The following does the trick:
<HTML>
<HEAD>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
function displayNetworkShares() {
var WshNetwork = new ActiveXObject("WScript.Network");
var Drives = WshNetwork.EnumNetworkDrives()
var DriveInfo = new Array()
var j = 0
var content = "<h1>Drive Mapping List</h1>"
for (i = 0; i < Drives.length; i++) {
content += "<p>" + Drives.Item(i) + "</p>"
}
document.write(content)
}
</SCRIPT>
</HEAD>
<BODY>
<form>
<input type="Button" name="Button1" value="Give list" onClick="displayNetworkShares()">
</form>
</body>
</html>
please let me know if you notice any apparent errors or problems.
i'd really appreciate if people who have mapped network drives would please cut n paste this code and save it as a '.html' file, open it using IE and let me know what happened.
also, is there anyway of doing the same thing in Netscape/other browsers??? |
| |
March 1st, 2003, 08:20 PM
|
#3 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,019
|
yep it works.. the user will get a warning about accessing an activex control though.
Other browsers won't support activex controls so unless they had an exe possibly no w/o some form of interpreter installed locally like Perl (that I know of at least) |
| |
March 3rd, 2003, 08:17 AM
|
#4 (permalink)
| | Member
Join Date: Aug 2002 Location: Downunder
Posts: 432
|
phew!!
thanks for replying vass...
i already delivered the product anyways  |
| |
March 3rd, 2003, 08:28 AM
|
#5 (permalink)
| | Retired mostly.
Join Date: Oct 2001 Location: Finland
Posts: 5,143
|
That's amazing.
-M
//edit:
Is there a site that explains how to do these things with js?
Last edited by muno : March 3rd, 2003 at 08:34 AM.
|
| |
March 3rd, 2003, 08:53 AM
|
#6 (permalink)
| | Member
Join Date: Aug 2002 Location: Downunder
Posts: 432
| |
| |
March 3rd, 2003, 10:37 PM
|
#7 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,019
|
for jscript the objects are the same as vbscript, so should just have to adapt it for JS |
| |
March 4th, 2003, 03:21 AM
|
#8 (permalink)
| | Retired mostly.
Join Date: Oct 2001 Location: Finland
Posts: 5,143
|
I tried looking at that site but it didn't have any tutorials to do stuff like you just did.
I know js a little, but not enough to understand what you did.
-M |
| |
March 4th, 2003, 04:01 AM
|
#9 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,019
|
Try a google search on
wscript.network jscript tutorial
I'm not familiar with JS, I know more vbs and the two are essentially the same with the methods and properties they call.. only difference is the obvious syntax. So if you see something done in vbs you maybe able to mold it into JS for your purposes... and if not just ask  |
| |
March 4th, 2003, 07:53 AM
|
#10 (permalink)
| | Member
Join Date: Aug 2002 Location: Downunder
Posts: 432
| Quote: Originally posted by muno
I know js a little, but not enough to understand what you did.
-M | well, i had one heck of a time trying to find a tutorial about this. firstly it was very hard to identify what exactly i was looking, tried googling, forums, without much luck. then i stumbled upon this http://www.civilsolutions.com.au/pub...getuncpath.htm
but this happened to be in foxtalk.....beats me...but then the explanation gave me ideas and i found the wshScript thingy.
then i found the winguides site that i linked in one of the previous posts... that explained the 'EnumNetworkDrives()' method...
frankly, dunno where a readymade tutorial is...
u can use the code that i pasted in one of the previous posts to map network drives to their shares. then store them in two different arrays and manipulate the arrays accordingly i suppose....
do let us know if u find any tutes...
i might just write one if i get time 
Last edited by nishark : March 4th, 2003 at 07:59 AM.
|
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |