I am working on an intranet website, this does not have communication with the internet, so security problems should not exist. The point is that I require that when the user is in a form when entering an option in which he will request the path to save files he has to select it but it is in the server NOT in the user's machine, once there only you have to select the directory and the path or path must appear in the input enabled for it. The project is .net MVC3 deal with JqueryFileTree but it only gives me the path to the project folder.
[HttpPost]
//notice the added additional params to the expected request variables
//these appear to match the names of the jQuery options
public virtual JsonResult GetFiles(string dir, bool multiSelect,
bool onlyFolders, bool onlyFiles)
{
const string baseDir = @"../";
dir = Server.UrlDecode(dir);
string realDir = Server.MapPath(baseDir + dir);
//validate to not go above basedir
if (!realDir.StartsWith(Server.MapPath(baseDir)))
{
realDir = Server.MapPath(baseDir);
dir = "/";
}
List<todosModelosBaseDatos.FileTreeViewModel> files = new List<todosModelosBaseDatos.FileTreeViewModel>();
DirectoryInfo di = new DirectoryInfo(realDir);
foreach (DirectoryInfo dc in di.GetDirectories())
{
files.Add(new todosModelosBaseDatos.FileTreeViewModel() { Name = dc.Name, Path = String.Format("{0}{1}\", dir, dc.Name), IsDirectory = true });
}
foreach (FileInfo fi in di.GetFiles())
{
files.Add(new todosModelosBaseDatos.FileTreeViewModel() { Name = fi.Name, Ext = fi.Extension.Substring(1).ToLower(), Path = dir + fi.Name, IsDirectory = false });
}
//lets filter some results using the properties of
//the 'FileTreeViewModel()' class
//I have no idea how you are wanting to use multiSelect, so
//it has been left out of this example.
if (onlyFolders)
{
files = files.Where(x => x.IsDirectory).ToList();
}
if (onlyFiles)
{
files = files.Where(x => !x.IsDirectory).ToList();
}
return Json(new { data = files});
}
This exercise only gives me C: \ users \ desktop \ Project folder
If you show me the folders contained in the project but that is not what I require, I require a more in-depth browser that could navigate through the server or at least in folders defined for it. Does anyone have any ideas or books?