Pergunta

I am trying to upload a photo captured with phonegap using filetransfer;I managed with android , but it doesn't work on windows 8, in fact the problem I see is due to the url of the image; under android is file ://url but on Windows 8 it is something kind of blob:1234566778rerui2, help me plz, here is the code

<!DOCTYPE html>
<html>
<head>
<title>Exemple de transfert de fichier</title>

<script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
<script type="text/javascript" charset="utf-8">

    // Attendre que PhoneGap soit prêt
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // PhoneGap est prêt
    //
    function onDeviceReady() {

        // Récupérer l'URI d'un fichier image à partir de la source spécifiée
        navigator.camera.getPicture(uploadPhoto,
                                    function(message) { alert('Echec de récupération du fichier'); },
                                    { quality: 50, 
                                    destinationType: navigator.camera.DestinationType.FILE_URI,
                                    sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY }
                                    );

    }

    function uploadPhoto(imageURI) {
        var options = new FileUploadOptions();
        options.fileKey="file";
        options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
        options.mimeType="image/jpeg";

        var params = new Object();
        params.value1 = "test";
        params.value2 = "param";

        options.params = params;

        var ft = new FileTransfer();
        ft.upload(imageURI, "http://un.serveur.com/upload.php", win, fail, options);
    }

    function win(r) {
        console.log("Code = " + r.responseCode);
        console.log("Réponse = " + r.response);
        console.log("Envoyé = " + r.bytesSent);
    }

    function fail(error) {
        alert("Une erreur est survenue : Code = " = error.code);
    }

    </script>
    </head>
   <body>
   <h1>Exemple</h1>
    <p>Transfert de fichier</p>
 </body>
  </html>
Foi útil?

Solução

we have to change on the corodova.js for windows 8 because there is a bug there , you can check this link: https://groups.google.com/forum/#!topic/phonegap/h2k-GeBJ0kY

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top