This question is locked. New answers and comments are not allowed.
Below is the code I'm using to allow a user to take a picture and then upload it to a .net web server. When I attempt to upload the file using the FileTransfer object, I get the following error:
"Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)"
All the aspx page does is send me an email if it gets called. Bringing the URL up in a browser sends the desired email but the app itself never actually triggers the email. Any insight would be greatly appreciated.
--------------------------------------------------------------
<code>
function readyPhoto() {
photoApp = new photoApp();
photoApp.run();
}
function photoApp(){}
photoApp.prototype={
_captureCount: 0,
_captureArray: null,
run: function(){
var that=this;
$('#capturePhotoButton').click(function() { that._capturePhoto.apply(that,arguments); });
$('#getPhotoFromLibraryButton').click(function() { toastr.info('Get Photo From Library Called'); });
$('#photoSaveUpload').click(function() {
if (that._captureCount > 0) {
var photoTitle = $('#photo').val();
if (photoTitle.length > 0) {
toastr.info('path: ' + that._captureArray[0].fullPath,'Photo Upload Called');
var ft = new FileTransfer(),
postURI = encodeURI('<the_url_to_post_to>'),
fileURI = that._captureArray[0].fullPath,
name = that_.captureArray[0].name;
try {
ft.upload(fileURI,postURI,
function(result) {
toastr.success('Upload success: ' + result.responseCode);
toastr.success(result.bytesSent + ' bytes sent');
},
function(error) {
toastr.error('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
catch(err) {
toastr.error(err.message);
}
} else {
toastr.error('Please provide a title for this photo.','Photo Upload Error');
}
} else {
toastr.error('A photo has yet to be taken!','Photo Upload Error');
}
});
},
_capturePhoto:function() {
var that = this;
navigator.device.capture.captureImage(
function() { that._captureSuccess.apply(that, arguments); },
function() { photoApp._onFail.apply(that, arguments); }
,{
limit:1
});
},
_captureSuccess:function(capturedFiles) {
var that = this;
that._captureCount = capturedFiles.length;
that._captureArray = capturedFiles;
/* the rest of this code only works for one image. may need to be revised when we move to handle multiple images */
$('#smallImage').attr('src',that._captureArray[0].fullPath);
},
_onFail: function(error) {
toastr.error('Failed! Error: ' + error.code);
}
}
</code>
"Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)"
All the aspx page does is send me an email if it gets called. Bringing the URL up in a browser sends the desired email but the app itself never actually triggers the email. Any insight would be greatly appreciated.
--------------------------------------------------------------
<code>
function readyPhoto() {
photoApp = new photoApp();
photoApp.run();
}
function photoApp(){}
photoApp.prototype={
_captureCount: 0,
_captureArray: null,
run: function(){
var that=this;
$('#capturePhotoButton').click(function() { that._capturePhoto.apply(that,arguments); });
$('#getPhotoFromLibraryButton').click(function() { toastr.info('Get Photo From Library Called'); });
$('#photoSaveUpload').click(function() {
if (that._captureCount > 0) {
var photoTitle = $('#photo').val();
if (photoTitle.length > 0) {
toastr.info('path: ' + that._captureArray[0].fullPath,'Photo Upload Called');
var ft = new FileTransfer(),
postURI = encodeURI('<the_url_to_post_to>'),
fileURI = that._captureArray[0].fullPath,
name = that_.captureArray[0].name;
try {
ft.upload(fileURI,postURI,
function(result) {
toastr.success('Upload success: ' + result.responseCode);
toastr.success(result.bytesSent + ' bytes sent');
},
function(error) {
toastr.error('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
catch(err) {
toastr.error(err.message);
}
} else {
toastr.error('Please provide a title for this photo.','Photo Upload Error');
}
} else {
toastr.error('A photo has yet to be taken!','Photo Upload Error');
}
});
},
_capturePhoto:function() {
var that = this;
navigator.device.capture.captureImage(
function() { that._captureSuccess.apply(that, arguments); },
function() { photoApp._onFail.apply(that, arguments); }
,{
limit:1
});
},
_captureSuccess:function(capturedFiles) {
var that = this;
that._captureCount = capturedFiles.length;
that._captureArray = capturedFiles;
/* the rest of this code only works for one image. may need to be revised when we move to handle multiple images */
$('#smallImage').attr('src',that._captureArray[0].fullPath);
},
_onFail: function(error) {
toastr.error('Failed! Error: ' + error.code);
}
}
</code>