Reputation: 884
I am new to window-8 application development. I want to create a simple javascript photo application. In my application, I want to show an assets folder for users to pick images they choose. Can someone help me with this?
Upvotes: 0
Views: 395
Reputation: 11720
Since you are using JS to construct your app, all you need to do is write up a small script that lists out the path to the assets you have put up in that folder and link it via a HTML page. Are you trying to dynamically do this? I don't think such a solution exists..
Edit: On second thoughts, have you considered using a promise to run the script everytime a new resource is added to the folder? Keep a check on the folder and raise a flag when a resource is added, based on flag status, call the promise to update the script will will contain the newly added resources. You may also need to consider the situation where a user may be selecting data while the promise may update the page. Appropriate use session storage to handle the situation.
Upvotes: 1
Reputation: 5225
There is a FilePicker control that lets you easily display images/files for the user to pick. Here is a code sample; download the JavaScript version. There are also guidelines with links to the API documentation here.
An excerpt from the code sample:
// Create the picker object and set options
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
// Users expect to have a filtered view of their folders depending on the scenario.
// For example, when choosing a documents folder, restrict the filetypes to documents for your application.
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);
// Open the picker for the user to pick a file
openPicker.pickSingleFileAsync().then(function (file) {
if (file) {
// Application now has read/write access to the picked file
WinJS.log && WinJS.log("Picked photo: " + file.name, "sample", "status");
} else {
// The picker was dismissed with no selected file
WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
}
});
Upvotes: 0