简体   繁体   中英

“Open File” dialog default folder location

I have a razor file like this:

@{
    ViewBag.Title = "bid_import";

    using (Html.BeginForm("ImportBid", "Bid", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        <input type="file" name="file" value="" />
        <input type="submit" value="IMPORT BID" />
    }
}

that lets you upload a file.

This is in an MVC 4 web app.

All I want to do is have the "open file" dialog box default to a specific folder path/location. Google wasn't yielding good results. Hopefully someone here can help me out! Thanks in advance for the help, and let me know if I need to clarify.

CLARIFICATION: yes, this is a web application, but I only want to set the default folder location to help the other developers working on the app. So I can assume that they have the same folder paths/contents as I do.

You can not access client file system by Javascript because of security reasons. The browser will open the path which it decide it should open (usually last path). If you really want to do that you should use plugins such as Adobe Flash or Silverlight which gives the client to access the file system.

Usually by default the browser will show the last location that a user downloaded to. You cannot control this, think about it, how would you handle different operating systems even, let alone disk names/folder structures etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM