Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
var app = {
// Application Constructor
initialize: function() {
// Bind Event Listeners
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
// deviceready Event Handler
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI
function onFail(e) {
function onSuccess(uri) {
document.querySelector("#img").src = uri;
console.log("ok i set the uri");
// Update DOM on a Received Event
receivedEvent: function(id) {
console.log('Received Event: ' + id);
Copy link

bfarrgaynor commented Sep 9, 2014

I don't think this works in iOS 7. I tried this with a hello world and added an element in my index.html called 'img'. eg. It loads the file picker but after you select the image it does not display. I attempted your example here after 6 hours of trying to make this very thing work in my app, I think there is a bug in iOS with loading images from the /tmp/ directory. I tried moving the image to the root but still can't display it to the user. I can upload it to a server a load it back in though, that seems to work.

Copy link

bfarrgaynor commented Sep 9, 2014

(I am running cordova 3.5.0-0.2.6)

I upgraded to 3.6.0-0.2.9, bug still exists when testing this code in the PhoneGap app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment