Phonegap从相机上传照片

时间:2015-04-16 18:33:02

标签: php android cordova

我是法国人,对不起我的英语(太糟糕了)! 我需要一些帮助,我必须做一个将照片从相机发送到我的wamp服务器的应用程序, 我尝试使用phonegap,但我遇到了问题, 我试试这段代码,但他说“做完了!” (我的警报)但我的www / PULZ目录中没有任何内容 请帮帮我,

function clearCache() {
    navigator.camera.cleanup();
}

var retries = 0;
function onCapturePhoto(fileURI) {
    var win = function (r) {
        clearCache();
        retries = 0;
        alert('Done!');
    }

    var fail = function (error) {
        if (retries == 0) {
            retries ++
            setTimeout(function() {
                onCapturePhoto(fileURI)
            }, 1000)
        } else {
            retries = 0;
            clearCache();
            alert('Ups. Something wrong happens!');
        }
    }

    var options = new FileUploadOptions();
    options.fileKey = "file";
    options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
    options.mimeType = "image/jpeg";
    options.params = {}; // if we need to send parameters to the server request
    var ft = new FileTransfer();
    ft.upload(fileURI, encodeURI("http://192.168.1.22/PULZ"), win, fail, options);
}

function capturePhoto() {
    navigator.camera.getPicture(onCapturePhoto, onFail, {
        quality: 100,
        destinationType: destinationType.FILE_URI
    });
}

我的UploadImg.php:

<?php
move_uploaded_file($_FILES["file"]["tmp_name"], './img/');

感谢您的帮助! :)

0 个答案:

没有答案
相关问题