|
我用手机相机插件时报错,经测试综合演示的相机插件也报错,是同样的错误。
是不是版本更新的原因?有新的代码吗?我的代码为:
- define(function(require){
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
- //require("$UI/system/lib/cordova/cordova");
- require("cordova!cordova-plugin-camera");
- Model.prototype.button2Click = function(event){
- var me = this;
- function onSuccess(imageURI) {
- me.uploadImage(imageURI);
- }
- function onFail(message) {
- return message;
- }
- navigator.camera.<font color="#ff00ff"><b>getPicture</b></font>(onSuccess, onFail, {
- //navigator.Camera.getPicture(onSuccess, onFail, {
- quality : 50,
- sourceType : 1//0、2为从相册文件中选择,1为拍照
- });
- };
- Model.prototype.uploadImage = function(imageURI) {
- alert("ok") ;
- return ;
- var deferred = when.defer();
- var options = new FileUploadOptions();
- options.fileKey = "fileAddPic";// 用于设置参数
- options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
- // 如果是图片格式,就用image/jpeg,其他文件格式上官网查API
- options.mimeType = "image/jpeg";
- // 这里的uri根据自己的需求设定,是一个接收上传图片的地址
- var uri = encodeURI("http://10.71.84.211:8080/news/uploadImage?userID=admin");
- options.chunkedMode = false;
- var params = new Object();
- params.id = "1";
- params.name = "test";
- options.params = params;
- var ft = new FileTransfer();
- function success(result) {
- deferred.resolve(imageURI);//改变执行状态
- navigator.notification.progressStop();
- //alert("成功" + JSON.stringify(result));
- }
- function fail(message) {
- alert("失败:" + JSON.stringify(message));
- }
- // 上传回调
- ft.onprogress = showUploadingProgress;
- navigator.notification.progressStart("", "当前上传进度");
- ft.upload(imageURI, uri, success, fail, options);
- }
- }
复制代码
|
|