jimmy_zejia
jimmy_zejia
  • 发布:2017-04-24 17:09
  • 更新:2017-04-25 11:01
  • 阅读:3637

关于plus.gallery.pick()问题

分类:HTML5+

使用plus.gallery.pick()选择图片上传 苹果一切正常 安卓后台报错 附件后台报错文件 查不到原因
前端选择图片部分代码

plus.gallery.pick(function(e) {  
            //              console.log("event:"+e);  
            var src = [];  
            for (var i in e.files) {  
                src.push(e.files[i]);  
            }  
            console.log('srcleng+=' + src.length)  
            var img = new Array(src.length);  
            for (var i = 0; i < src.length; i++) {  
                // console.log("name:" + name);  
                img[i] = new Image();  
                img[i].src = src[i];  
                img[i].onload = function(i) {  
                    return function() {  
                        EXIF.getData(img[i], function() {  
                            var name = src[i].substr(src[i].lastIndexOf('/') + 1);  
                            Orientation = EXIF.getTag(this, 'Orientation');  
                            if (Orientation == 6 && plus.os.name == 'Android') {  
                                rotate = 90;  
                            } else {  
                                rotate = 0;  
                            }  
                            console.log("rotate = " + rotate);  

                            plus.zip.compressImage({  
                                src: src[i],  
                                dst: '_doc/' + name,  
                                overwrite: true,  
                                quality: 50,  
                                rotate: rotate  
                            }, function(zip) {  
                                size += zip.size;  
                                if (size > (10 * 1024 * 1024)) {  
                                    return mui.toast('文件超大,请重新选择~');  
                                }  
                                console.log("filesize:" + zip.size + ",totalsize:" + size);  
                                var fileInputArray = feedback.getFileInputArray();  
                                imageIndexIdNum++;  
                                var placeholder = document.createElement('div');  
                                placeholder.setAttribute('class', 'image-item space');  
                                var up = document.createElement("div");  
                                up.setAttribute('class', 'image-up')  
                                    //删除图片  
                                var closeButton = document.createElement('div');  
                                closeButton.setAttribute('class', 'image-close');  
                                closeButton.innerHTML = 'X';  
                                //小X的点击事件  
                                closeButton.addEventListener('tap', function(event) {  

                                    setTimeout(function() {  
                                        feedback.imageList.removeChild(placeholder);  
                                    }, 0);  
                                    imgIndex = $(this).parent().index();  
                                    // imgArray.splice(imgIndex,1)  
                                    feedback.files.splice(imgIndex - 1, 1);  
                                    // feedback.newPlaceholder();  
                                    return false;  
                                }, false);  

                                //  
                                var fileInput = document.createElement('div');  
                                fileInput.setAttribute('class', 'file');  
                                fileInput.setAttribute('id', '' + imageIndexIdNum);  

                                if (feedback.files.length <= 9) {  
                                    placeholder.appendChild(closeButton);  
                                    placeholder.appendChild(up);  
                                    placeholder.appendChild(fileInput);  
                                    feedback.imageList.appendChild(placeholder);  
                                }  
                                /*   if (!self.parentNode.classList.contains('space')) { //已有图片  
                                       feedback.files.splice(index - 1, 1, { name: "images" + index, path: e.files[i] });  
                                       // showImg(e,index)  
                                   } else { //加号  
                                       placeholder.classList.remove('space');  
                                       feedback.addFile(zip.target);  
                                       feedback.newPlaceholder();  
                                       // showImg(zip.target)  
                                   }*/  
                                placeholder.classList.remove('space');  
                                feedback.addFile(zip.target);  
                                // feedback.newPlaceholder();  
                                up.classList.remove('image-up');  
                                placeholder.style.backgroundImage = 'url(' + zip.target + ')';  
                            }, function(zipe) {  
                                console.log(JSON.stringify(zipe))  
                                mui.toast('压缩失败!')  
                            });  
                        });  
                    }  
                }(i);  
            }  
        }, function(e) {  
            // mui.toast(e.message);  
        }, { filter: "image", multiple: true, maximum: 9, system: false });
2017-04-24 17:09 负责人:无 分享
已邀请:
小资电脑

小资电脑

在服务器上手工检测下后台接收到的文件

要回复问题请先登录注册