Reputation: 1861
I am trying to pick a file using FileOpenPicker in windows phone 8.1 by using phonegap, but its not working.
I use this code
public class Echo : BaseCommand
{
public void echo(string options)
{
try{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null){
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Picked photo: " + file.Name));
}
else{
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Operation cancelled"));
}
}catch (Exception e){
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error=>"+e.ToString()));
}
}
}
In phonegap
cordova.exec(success, error, "Echo", "echo");
function success(message) {
//upload_file(message);
alert(message);
}
function error(e) {
alert(e);
}
But i am getting error like this
can anyone guide me.....
Thanks in advance.
Upvotes: 1
Views: 777
Reputation: 8161
Sometimes MSDN documentation can be very messy.
PickSingleFileAsync(); // is not supported
Instead try this:
PickSingleFileAndContinue();
MSDN PickSingleFileAndContinue
Upvotes: 2