2 liyihongcug liyihongcug 于 2013.10.04 17:58 提问

jquery mobile如何上传一个文件以及如何拍照

jquery mobile代码如下总是失败
提示request failed

、$().ready(function ()
{
$('#save').click(function (e)
{
CalluploaderHandler();
});
});

function CalluploaderHandler()
{
$.ajax({
type: "POST",
url: "Services/UPloader.ashx",
contentType: "application/json; charset=utf-8",
success: OnComplete,
error: OnFail
});
return false;
}

function OnComplete(result)
{
alert('Success');
}

function OnFail(result)
{
alert('Request failed');
}






Filename:




2个回答

songzhiyong1121
songzhiyong1121   2013.11.27 16:15
已采纳

拍照:

function capturePhoto() {
        navigator.camera.getPicture(uploadPhoto, onFail, { 
            quality: 50, destinationType: Camera.DestinationType.FILE_URI 
        });
    }

上传

function uploadPhoto(imageURI) {
window.resolveLocalFileSystemURI(imageURI, function (fileEntry) {
    fileEntry.file(function (fileObj) {

        var path = fileObj.fullPath;
        console.log("FilePath=" + path);
        var options = new FileUploadOptions();
        options.fileKey = "file";
        var imagefilename = Number(new Date()) + ".jpg";
        options.fileName = imagefilename;
        options.mimeType = "multipart/form-data";
        options.headers = {
            Connection: "close"
        };
        var params = {
            //....
        };
        options.params = params;
        options.chunkedMode = false;
        var ft = new FileTransfer();
        var url = URL;
        ft.upload(path, encodeURI(URL), win, fail, options, true);
    });
});

}

u012331479
u012331479   2013.10.04 18:49

这个......不好意思

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!