palm基础----4 上传文件

需求:将palm手机上的文件上传到Http服务器端


文件上传
FileuploadAssistant.prototype.uploadHandler = function()
{
    
this.controller.serviceRequest('palm://com.palm.downloadmanager/',
    {
        method : 
'upload',
        parameters :
        {
            
'fileName' : "/media/internal/files/nami.jpg",
            
'fileLabel' : "myfile",
            
'url' : 'http://192.168.87.45:8088/WebDemo/uploadFile.do',
            
'contentType' : 'image/jpeg',
            
'postParameters' : 
            [{
                key : 
"username",
                data : 
"synnex",
                contentType : 
"text/plain"
            },
            {
                key : 
"password",
                data : 
"123456",
                contentType : 
"text/plain"
            }],
            
'subscribe' : true
        },
        onSuccess : 
function(resp)
        {
            Mojo.Log.info(
'Success : ' + Object.toJSON(resp));
        },
        onFailure : 
function(e)
        {
            Mojo.Log.info(
'Failure : ' + Object.toJSON(e));
        }
    });
}

 

method : 'upload'      表示文件上传

fileName                   表示待上传的文件全路径

fileLable                    表示服务器端接收文件时,用到的名称。(是必填项,如果不填写会导致上传失败)

url                             表示服务器处理文件上传的URL

contentType             表示上传的文件的 mime 类型

subscribe                  同上 download 解释

postParameters        表示随图片一起传递的信息,key就是字段的名称,data就是字段的值,服务器端可以使用 request.getParameter(key) 来获取 data 的值。经测试发现,postParameters中只能是字符串信息,不能再传递图片等二进制信息。。。

也就是说:一次只能上传一个文件

 

posted on 2010-11-26 23:24  TroyZ  阅读(206)  评论(0编辑  收藏  举报