1

I have created a PhoneGap based web app some time ago.

Since input type file is now possible on iOS 6, I want to use it and the native File API as well, but keep using PhoneGap to be able to put the app in the Appstore.

BTW: I have found this link, but this does not work: Everytime I access File functionality I get an ERROR from PhoneGap and it basically does nothing.

Update:

In fact getting the file (image) and sending it to the server works fine, but before that I want to resize the image (to reduce file size) by using canvasResize. When the function reader.readAsDataURL(file) is called, I get the following error:

-[CDVJKDictionary pathExtension]: unrecognized selector sent to instance 0x208892b0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CDVJKDictionary pathExtension]: unrecognized selector sent to instance 0x208892b0'

Update 2:

Here is the relevant code that I use:

var reader = new FileReader();
var fileInput = document.getElementById('ideaCommitFileInput');
var file = fileInput.files[0];
reader.readAsDataURL(file);
Community
  • 1
  • 1
Chagemei
  • 286
  • 6
  • 14

1 Answers1

0

If you are going to deploy your PhoneGap application on both iOS and Android, I would suggest using a regular file input field for iOS 6 devices and navigation.camera for Android and earlier versions of iOS devices, assuming you are dealing with image uploads.

As long as your app has enough 'native functionality', I doubt Apple App review would mind that you used HTML5 File API.

Here is a good example of using the File API to retrieve a Base64 encoded image string: Phonegap encode image base64.

Hope this helps.

Community
  • 1
  • 1
Zorayr
  • 23,770
  • 8
  • 136
  • 129
  • Thanks for your answer! In fact, that was the way I was trying to do. But the method reader.readAsDataURL(file) (with reader being a FileReader) creates the following error: -[CDVJKDictionary pathExtension]: unrecognized selector sent to instance 0x208892b0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CDVJKDictionary pathExtension]: unrecognized selector sent to instance 0x208892b0' I assume this error is due to the fact that my file object is one of a native HTML5 input, but the used FileReader expects a file object from PhoneGap. (See code above) – Chagemei Jan 14 '13 at 08:52