未捕获的ReferenceError:未定义FileUploadOptions

时间:2013-04-03 09:23:35

标签: cordova jquery-mobile file-upload

我正在尝试使用手机间隙上传照片,但我总是得到一个未捕获的ReferenceError。 我试图把cordova.js放在head标签的开头,但没有成功。 这是代码

的index.html

<head>
    <meta charset="utf-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>test</title>
    <script type="text/javascript" src="js/cordova-2.5.0.js"></script>      
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.3.0.min.css" />    
    <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="js/jquery.mobile-1.3.0.min.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</head>

index.js

(function($){
    var self = $.mobile.test = {
        init : function(){
            $(document).on('pagebeforeshow', '#login', function(){
                $('#access').off('click').on('click',function(){
                    self.comprobarAcceso();
                });                 
            });
            $(document).on('pagebeforeshow', '#registrarse', function(){
                $('#registro').off('click').on('click',function(){
                    self.registrar();
                });                 
            }); 

            $(document).on('pagebeforeshow', '#nueva', function(){       
                console.log("nueva live...");
                $('#sacar-foto').off('click').on('click',function(){
                    self.capturarFoto();
                });                 
                $('#crear').off('click').on('click',function(){
                        self.crear();
                });
            });

        },
        crear: function(){
            var win = function(r) {
                console.log("Code = " + r.responseCode);
                console.log("Response = " + r.response);
                console.log("Sent = " + r.bytesSent);
            }

            var fail = function(error) {
                alert("An error has occurred: Code = " + error.code);
                console.log("upload error source " + error.source);
                console.log("upload error target " + error.target);
            }

            var options = new FileUploadOptions();
            options.fileKey="file";
            options.fileName=fileURI.substr(fileURI.lastIndexOf('/')+1);
            options.mimeType="text/plain";
            var params = {}; 
            params.value1 = "test"; 
            params.value2 = "param";

            options.params = params;

            var ft = new FileTransfer();
            ft.upload(fileURI, encodeURI("http://some.server.com/upload.php"), win, fail, options);             
        }


};

self.init();

})(jQuery);

我在Chrome控制台上遇到错误: var options = new FileUploadOptions();

  

未捕获的ReferenceError:未定义FileUploadOptions。

似乎它没有加载科尔多瓦图书馆,但其他一切工作正常,甚至用移动相机拍照。

请帮忙!

0 个答案:

没有答案