lilinew 2013-10-04 09:58 采纳率: 100%
浏览 8460
已采纳

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条回答 默认 最新

  • Jerome_Song 2013-11-27 08: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);
        });
    });
    

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目
  • ¥15 数电几道习题,写出作答过程,ai一律不采用
  • ¥15 利用pthon计算薄膜结构的光导纳
  • ¥15 海康hlss视频流怎么播放
  • ¥15 Paddleocr:out of memory error on GPU
  • ¥30 51单片机C语言数码管驱动单片机为AT89C52