How to upload-download a file to-from 'www' folder with Cordova?(Android)

100 Views Asked by At

I'm working on an app with Cordova and the cordova-sqlite-ext plugin (brodysoft) to edit a pre-populated sqlite database that is located in the www folder, everything works fine but now I want to download or export that modified database so the user can send it by email or whatever, also upload or import a database (to replace to older one) using an input type file.

This is the code that works on browser but not on mobile phone:

        //IMPORT BD
        function importar_bd(){
            var formData = new FormData();
            formData.append("archivo", document.getElementById("importar_bd_file").files[0]);
            var ruta = "upload.php";
            $.ajax({
                url: ruta,
                type: "POST",
                data: formData,
                contentType: false,
                processData: false,
                success: function(respuesta)
                {
                    alert(respuesta);
                },
                error: function() { 
                    alert("Some error message here"); 
                } 
            });
            return false; 
        }

        //EXPORT BD
        function exportar_bd(){
            window.location.href = "my_db.db";
        }

I can understand that php is not supported but the export function is not working either.

Can anybody that have made this before show me an example to achieve it? Its possible to make it without other plugin?

Thank you all.

0

There are 0 best solutions below