我正在使用以下代码上传图片。它适用于Android和iPhone,但不适用于playbook。我正在使用phonegap 1.4.1 - 它总是调用下面的失败功能,警报显示总是'未定义'。 config.xml是根据黑莓样本。除上传功能外,该应用程序仍然有效。
提前致谢。
...
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=pictureFlag.substr(pictureFlag.lastIndexOf('/')+1).split('.')[0];
options.mimeType="image/jpeg";
options.chunkedMode = false;
var param = new Object();
param.fromEmail = $('#recipeDetailsFromEmailId').val();
param.to = $('#recipeDetailsToEmailId').val();
param.emailType = $('#recipeDetailsSendEmailId').attr('checked');
param.sendMeCopy = $('#recipeSendEmailCopyId').attr('checked');
param.message = $('#recipeDetailsMessageId').val();
param.imageType = imageTypeFlag;
param.language = localStorage.language;
param.recipeName = nameFlag;
param.prepTime = prepTimeFlag;
param.serves = servesFlag;
param.picture = pictureFlag.split('.')[0] + '.' + pictureFlag.split('.')[1];
param.ingredients = ingredientsFlag;
param.preparation = prepDescriptionFlag;
param.deviceId = devicePlatform.toLowerCase();
param.category = $("#selectCategoryId option[value='" + categoryFlag + "']").text();
options.params = param;
var ft = new FileTransfer();
ft.upload(pictureFlag, url, win, fail, options);
...
功能失败(消息){
//alert(message)
//alert("evt.target.error.code: " + message.target.error.code);
alert("An error has occurred: Code = " + message.code);
alert("upload error source " + message.source);
alert("upload error target " + message.target);
答案 0 :(得分:0)
您可以尝试在true
函数的末尾添加upload
选项,如下所示:
ft.upload(pictureFlag, url, win, fail, options, true);