1

Using trigger.io on Android one can't upload files using the plain HTML <input type="file"> element. On iOS this works fine.

The underlying problem seems to stem from the webview not having a native filepicker, and trigger.io haven't implemented one for their webview.

This question shows a solution on native (non trigger.io) apps: File Upload in WebView

Anyone know if this is possible to solve?

(Without using forge.file.getImage, which is what we use now. The problem with forge.file.getImage is that the file isn't a normal Javascript File object, can't be uploaded using FormData/XHR2, etc).

Community
  • 1
  • 1
sandstrom
  • 14,554
  • 7
  • 65
  • 62

1 Answers1

1

You can use the file module to allow the user to select a file to upload which you can then upload using forge.ajax.request.

See http://docs.trigger.io/en/v1.4/modules/file.html for more details.

Connorhd
  • 2,476
  • 14
  • 15
  • Thanks! I'm using `forge.file.getImage` right now, but that brings many problems. Ordinary `File` objects aren't returned, doesn't work with `FormData`, etc., so I'm looking for a plain HTML/JS cross-browser solution. – sandstrom Jan 14 '13 at 15:12
  • It would be nice to be able to do that, unfortunately it is very difficult to do in both a cross platform and efficient way (it isn't really reasonable to transfer the contents of a file to Javascript as a string). `` support was only added to iOS in version 6 which is one reason we haven't used that. – Connorhd Jan 14 '13 at 18:25
  • We're using `File` objects in iOS 6, works fine (uploads, image rotation, etc). No problem in the Android browser either. The only hindrance is the missing filepicker in the webview on Android. – sandstrom Jan 14 '13 at 21:57
  • The problem with that is it doesn't work on iOS 5, which is still a considerable portion of devices, which is why we have the forge.file API which works on all devices we support. – Connorhd Jan 14 '13 at 22:23
  • iOS >= 6.0 has as 86% adoption now (iOS 5 is at about 10%, the other 4% is iOS 4). http://chitika.com/ios-version-distribution-update – sandstrom Mar 14 '13 at 10:15