HTML5拍照上传图片&Phonegap封装HTML5调用Android相机拍照上传到PHP端

来源:互联网 发布:东莞网络推广 编辑:程序博客网 时间:2024/05/01 21:46

HTML5拍照:

参考网址:http://blog.csdn.net/hfahe/article/details/7354912 

上传部分也可以用ajax:

$.ajax({
                url: 'http://ip/uploadphoto.php',
                type: 'post',
                context: this,
                data:  {blob:blobdata},   //blobdata就是blobdata= imgData.substr(22);
                async: true,
                dataType: 'json',
                withCredentials:true,
                success: function (htmlVal) {
                    //alert("blobdata==="+blobdata);
                    if(htmlVal.status=="success"){
                        alert("Upload photo success!");
                        setTimeout("photo_show_hide()",2000);
                    }
                    else{
                        alert("Upload photo fail!")
                    }
                }, error: function (e) {
                        alert(e.responseText);
                }
            });
PhoneGap拍照上传:

主参考网址:http://www.phonegapcn.com/file

参考:http://www.cnblogs.com/flyingzl/articles/3115457.html

不过封装成APK后会提示FileTransfererror.code=3的错误 ,所以要加入:

options.headers = {        Connection: "close"    }    options.chunkedMode = false;
参考网址:http://stackoverflow.com/questions/19275268/phonegap-file-transfer-of-picture-fails-on-every-other-picture-error-code-3-wit


0 0
原创粉丝点击