• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1341
  • Last Modified:

asp.net -Retrieve client side UNC rather than mapped network drive when using asp:fileupload

Hello Everyone!

I think the nature of the question is simple, but i have had no luck googling or finding anything exactly what i'm after. I only hope the solution is as simple as i believe the question to be.
Here's the deal:
aspx page, c# code behind with an <asp:FileUpload /> control.
this page is used only in a local domain.  Some administrative users are going to select a file from somewhere within the intranet (a picture file), which the fileUpload will grab the file path & name and upload to SQL Server record. (the text path, not the image).  This is done so that when other users navigate to a report, page, etc. pertaining to a given individual, i can display the image by referencing the network path to the image.
simple enough and works great.
-here's the problem.

-for most users (i say most rather than 100%, because i never say 100% because you never know) have mapped network drives to these network shares.
A simplified example is:
Photos located:

\\myserver\mydir\ is mapped to drive "X:" on the client box.

when they use the fileupload control, it returns:

rather than the full UNC:

KEEP IN MIND, this is in terms of the client, the webserver doesn't even have these mapped network drives.

-I want/need this because i know someone will throw a usb drive in the machine, which will mess up the drive letters or someone's login script didn't fire on a laptop which hadn't yet established a suitable connection, etc. etc. i see a mess i'd like to avoid if i could just stick to straight UNC paths. This seems very simple, but can't find anything (either on the tag or to be called in the codebehind to get here, i'd even settle for a c# function to feed in the mapped drive letter and mine out the unc or ajax, javascript, whatever. i'm just at a loss. please help!
many thanks
  • 2
1 Solution
I guess it might not be possible as the file browse control is a general one and may behave differently based on the browser. Basically you can't program the default file upload control like that I suppose.
JohnSingletonAuthor Commented:
hmmm. i'm seriously baffled. it seems like a simple request/problem but i've come up empty no matter how i try to solve it.  

the next ugliest thing is to force a replace on the path (replace(strFilePath,"X:\","\\myserver\mypath\"))
i really don't want to do this!
below is the code i have, which works great for returning what i want (less the UNC path of the share rather than mapped drive)

-realize i've stripped most of my code away to get to the point of what i'm trying to accomplish without cluttering with unnecessary info.

-my research has pointed toward javascript or activeX if its even possible at all???

Thanks, Fingers still crossed!
Relevant aspx section
            <br /><b>Change:</b>
            <asp:FileUpload ID="fuEmpPhoto" runat="server" />
            <br />
Relevant C# section, where path is being returned
    protected void ods_EmpMain_OnUpdating(object sender, ObjectDataSourceMethodEventArgs e)
        string strFileUpload = ((FileUpload)fv_EmpMain.FindControl("fuEmpPhoto")).PostedFile.FileName.ToString();
        if (strFileUpload != string.Empty)
            e.InputParameters["employee_photo"] = strFileUpload;

Open in new window

activex may be the way to go. Replacing the x: with some path may not be reliable.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now