Link to home
Start Free TrialLog in
Avatar of ssdanu
ssdanu

asked on

Determine a universal network path from a drive letter path using input type-file and javascript

HI


I am using <input type=file>  tag to give user the place to browse and select the  link to the file.IO want tio store those liks in the database. But I ant to store actual path names from the  mapped path name user has selected thru browse. What is the way to do that

 e.g user has selected path

I:\Welcome.asp

where I drive is mapped to
\\MM5206\DQ


so the actual path of the file is

\\MM5206\DQ\welcome.asp

I want to store this actual path in the database instead of the path I:\welcome.asp wntered by the user  after he is finished selecting the path.
 PLease help me by telling the way to do it

 It is very urgent!!



 Thanks in advance

Best Regards
ssdanu
Avatar of third
third
Flag of Philippines image

i don't think there is a way to do that.
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW: DOn't expect to be able to do this without using an ActiveX object... that would be a security breach, and nobody wants THAT!
-- Dan
maybe this:
=============
<script>
function runit(obj)
{
      obj.form.userpath.value="\\\\MM5206\\DQ\\"+obj.value.replace(/^[a-z\:\\]{3}/i,"")
}
</script>
<form>
      <input type=file name=userfile onchange=runit(this) style=width:700px><br>
      <input type=text name=userpath style=width:700px>
</form>
devic,
How can that answer the question "Determine a universal network path from a drive letter"?
@ DanRollins,

i know that:
   I:\ drive is mapped to  \\MM5206\DQ

i know where file is now
    I:\Welcome.asp


examples:
I:\Welcome.asp
     \\MM5206\DQ\ + Welcome.asp =  \\MM5206\DQ\Welcome.asp

I:\AnotherFolder\Welcome.asp
 \\MM5206\DQ\ + AnotherFolder\Welcome.asp =  \\MM5206\DQ\AnotherFolder\Welcome.asp

i think is right, not tested, just an idea.
If you already know the mapping, then there would seem to be no need to find it out...
i agree, but as i understood, ssdanu needs it :)
Avatar of ssdanu
ssdanu

ASKER

Hi

 I tried the code given by DanRollins
It gave an exception thata Automation server cannot create object
Whata do I need to do in addition to get thata code work.
 What could be the reason for that exception
And one more thing is user may add different mapped paths it is not fixed as user will everytime add (I:\  path).
 Also it is quite possible that different users can have different mapped drive for same network location
and I would not be knowing these mapped drives already.
so it has to be decided at the runtime as to what location the user entered path is mapped to...


So I need some way to dynamically determine the mapped drives actual network location


Thanks and Regards
ssdanu

THat's what I thought... you need to learn the UNC path at runtime.

The "WScript.Network" activeX object is available on a standard install of Win2000.  As it *is* an activeX, there are several things that mught prevent it from running on some (many) computers becasue of security reasons.  

Try putting that code into a file named TEST.HTA and double-click it to run it on your own computer.
I have exactly the same problem. Dan Rollins' solution is good but the only problem is that it won't create the ActiveX object. Is it a security problem? Cause I have tried it in a .HTA file and it works fine.
There is a security problem when running ActiveX code called from an HTML script -- because HTML scripts need to run in a "sandbox"  That is, the user is specifically protected from running programs that could harm the computer or give away information to anyone who wants it.  HTA files are "local application prograams" which are treated under a different security scenario -- the same as an EXE or BAT file.  It is assumed that the operator explicilty wants to be able to run this program... unlike a click on a web page where the user may or may not want to run the program.
Maybe I have a solution. I tried using VBScript instead of Javascript, and it worked. For my part I can do this cause i'm using Script in completion of my ASP.NET pages.

Try using :

dim oBj
Set oBj = CreateObject(("WScript.Network")

Nevermind, does not work, I realised that it was doing the same thing, same error... I bugged here!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial