Anders Arpi
Anders Arpi

Reputation: 8397

Solutions to allowing intranet/local file access in an HTML5 application?

I am all too aware of the fact that even with the new FileAPI it's not possible to access the local path of a file added using a file input field or drag-and-drop. Whether or not this is good, bad or ugly is not the issue here. According to the FileAPI specs local file access is not to be implemented, and so I'm not holding my breath.

But let's just pretend I'm in a situation with the following fixed parameters:

And by access I don't mean access file data, but rather be able to relay a file drag-and-drop/select event to some other API by feeding the third party the file's local path, so that the third party can pick up the file and do some sort of work on it. This can be likened to using an input[type=file] field as you would an OpenFileDialog in .NET - i.e. the point is to feed the application a file path, not an actual file.

I realise that out of the box this is probably not possible. But I also think that there must be some sort of solution to the problem.

Some ideas I've been toying with are:

... and that's about it.

Any snazzy suggestions? Wise words? Helpful links? Snarky comments?

Thanks.

Edit: For anyone curious about it, this was very simple using Silverlight as per jgauffin's suggestion below.

From the Silverlight codebehind (using elevated privileges):

private void fileBtn_Click(object sender, RoutedEventArgs e)
{
    //prompt file select dialog in Silverlight:
    var dlg = new OpenFileDialog();
    dlg.ShowDialog();
    //call JavaScript method and feed it the file path:
    HtmlPage.Window.Invoke("onFileSelected", dlg.File.FullName);
}

Upvotes: 2

Views: 5763

Answers (2)

jgauffin
jgauffin

Reputation: 101150

You'll probably have to use something that runs in the browser like flash or silverlight.

Since it's an internal app I would use silverlight as everything else is in .NET. It should be enought to only make the file access part in the plugin.

Here is an article about local file access: https://www.wintellect.com/silverlight-4-s-new-local-file-system-support/

Upvotes: 3

steven
steven

Reputation: 31

does the server hosting the site have access to the network of pc's?

you could just list all the files that way.. build a small ajax script like a file dialog that will have php or whatever sending back the structure

no plugins needed, works on all browsers... :)

Upvotes: 3

Related Questions