adam griffin
Posts: 0
Joined: Tue May 21, 2013 8:44 pm

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

I get this error when trying to upload a file. I am using the same camera services for two different uploads. I use a if statement to tell the two different uploads apart. I set the data.imageURI to localStorage. And use a function to call the FileTransfer upload. This is snippets of the code im using:

/Choose witch file is uploading/
if(localStorage.getItem("photoType")==1){

Code: Select all

 localStorage.setItem("TEMP_profile_url",String(data.imageURI)); 

}
else if(localStorage.getItem("photoType")==0){
localStorage.setItem("TEMP_background_url",String(data.imageURI));

}

/SOME OTHER CODE/

/Function that will be doing the uploading/
function sendProfile(){
alert("Called Profile");
var ft = new FileTransfer();
ft.upload(localStorage.getItem("TEMP_profile_url"), uri, win, fail, options);
}

function sendBackground(){
alert("Called Background");
var ft2 = new FileTransfer();
ft2.upload(localStorage.getItem("TEMP_background_url"), uri, win2, fail, options);
}

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

Hello Adam,

Please clarify are these variables defined: uri, win, fail, options?
Please check, do you call the function that you need? You should debug your application and look for what is wrong - what variable is not set.

adam griffin
Posts: 0
Joined: Tue May 21, 2013 8:44 pm

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

I think it is talking about the first parmeter. Uri,win,fail, and options are funcitions that I declare else where. They work perfectly. When I replace the first if statement with var file = data.imageURI; ft.upload(file, uri, win, fail, options); Everything is ok. Is something change when I set the data.imageURI to localStorage?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

Adam,

Everything seems to be right. Please check what is recorded in your local storage. Before calling method .upload you should do alert of corresponding local variable storage

adam griffin
Posts: 0
Joined: Tue May 21, 2013 8:44 pm

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

I checked the variable and it shows the image file location on my device. I don't know what the problem can be. Could you guys take a look at it?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

Hi Adam,

Sure. Could you please share the app and send steps to reproduce?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

Hi Adam,

Please try outputting values of localStorage.getItem("TEMP_profile_url") and uri for sending profile.

adam griffin
Posts: 0
Joined: Tue May 21, 2013 8:44 pm

Wrong type for parameter "undefined" of FileTransfer.upload: Expected String

This what is displayed in the localStorage.getItem("TEMP_profile_url")

Return to “Issues”