This is a migrated thread and some comments may be shown as answers.

FileTransfer Upload: Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)

1 Answer 193 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
TimmyTooTall
Top achievements
Rank 1
TimmyTooTall asked on 15 Apr 2013, 06:23 PM
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>

1 Answer, 1 is accepted

Sort by
0
TimmyTooTall
Top achievements
Rank 1
answered on 15 Apr 2013, 06:33 PM
all it takes is posting something publicly before you realize your own mistake ... ugh ... 

line 31 had "name = that_.captureArray[0].name;"

and it actually should have been "name = that._captureArray[0].name;"

.... sigh ....
Tags
General Discussion
Asked by
TimmyTooTall
Top achievements
Rank 1
Answers by
TimmyTooTall
Top achievements
Rank 1
Share this question
or