locked
Something like openfiledialog in HTML / JS

    Question

  • Hi all,

    I'd like to write an HTML5 / JS metro application. In this app I want the user to be able to select a file in his hard disk, and upload it to a server / cloud.

    Is such a thing possible just with a JS metro style visual studio project? Is there an equivalent of c# openfiledialog in Javascript? Or do I have to combine c# on the server side and JS?

    Thanks a lot for any feedback!

    Sunday, July 1, 2012 4:11 PM

Answers

  • Yes, there is a FilePicker and it is pretty easy to work with.  See this: http://msdn.microsoft.com/library/windows/apps/BR207847

    Little bit of a warning, the FilePicker creates a non-standard StorageFile object.  If you want to XHR the data or manipulate it client side using 3rd party libraries you'll likely need to either convert the data to a blob or convert the StorageFile to a W3C File object.  You can do that with either MSApp.createFileFromStorageFile or MSApp.createBlobFromRandomAccessStream.  These methods are a bit hidden, not really documented that well but they work.

    Sunday, July 1, 2012 4:34 PM