UNC Path from Share Drive

W

wreed

Is there a way on a button press to create a browse for a file box and
then when they pick a file on a share drive to convert it to a UNC
path and that way I would save the unc path into a table and not have
to store the file? If anyone has a solution to getting the UNC path I
would love it. Please.
 
N

news

Is there a way on a button press to create a browse for a file box and
then when they pick a file on a share drive to convert it to a UNC
path and that way I would save the unc path into a table and not have
to store the file? If anyone has a solution to getting the UNC path I
would love it. Please.

I do this on our Intranet - and seeing as you are storing UNC paths
I can only assume this is also for your own intranet as internet
clients
won't be able to see the same LAN as internet servers.

This works on Windows IE 6 and 7 - basically use two input
elements, one a text input, the other a file input, then copy the
path from the file input to the text input when it changes.

You could make sure it is a UNC path on the way I suppose.
Note that the second input has no name attribute. This stops
the file contents being submitted with the form.

<form action="destination.page" method="post">
<input type="text" name="filepath" value="">
<input type="file" style="width:0px;" title="browse for file"
onchange="this.form.filepath.value = this.value;">
</form>

In firefox 2, the dummy file input element is not collapsed, so
you see two copies of the path. But we don't (yet) support firefox
on our intranet as we use a lot of activeX components to display
3D models.

Test it at http://www.chthonic.f9.co.uk/test/filebrowsetest.htm
 
W

wreed

How does this change it to a UNC path, all I see is once I browse the
Z:\whatever not the \\servername\blah.....

Am I missing something?
 
N

news

How does this change it to a UNC path, all I see is once I browse the
Z:\whatever not the \\servername\blah.....

Am I missing something?

Your users are selecting a mapped drive to get to the share?
Well, no wonder it doesn't work. I thought your problem
was how to get the path instead of the file itself, not how
to translate a local mapped-drive path into a UNC path

Solutions... 1) Get them to type the UNC path instead. OK,
it sounds flippant, but moving over to using, say, DFS to
manage your shared storage locations is hugely, hugely better
than using mapped drives.

2) on the server, get the mapped drive path, and use WMI
to query the client machine for a list of mapped drives,
lookup z: and substitute the UNC path. This will work if
the server-side code has enough privileges to do the query
and the client computer isn't so busy that it takes ages
to reply. You won't be able to do this client-side.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top