PAGE / NUMPAGES
Appcan如何上传附件到服务器
需要的地方加上:οnclick=showActionSheet();
var uploadHttp = /upload.php;//请更换为你所使用的上传地址 文档收集自网络,仅用于个人学习
function showActionSheet(){
uexWindow.cbActionSheet=function (opId, dataType, data) 文档收集自网络,仅用于个人学习
{
if(data == 0)
{
paiopen();
}
else if(data == 1)
{
fileopen();
}
}
var value = "拍照上传;本地上传";
var mycars=value.split(";");
uexWindow.actionSheet("","取消",mycars);
}
function paiopen(){
uexCamera.cbOpen=function (opCode, dataType, data)
{
document.getElementById('pic').value = data;
upl0ad();
}
uexCamera.open();
}
function fileopen(){
uexImageBrowser.cbPick=function (opCode,dataType,data) 文档收集自网络,仅用于个人学习
{
document.getElementById('pic').value = data;
upload();
}
uexImageBrowser.pick();
}
function uexWidgetOneErrorCb(opCode, errorCode, errorInfo){ 文档收集自网络,仅用于个人学习
uexWindow.toast('0','5',errorInfo,2000);
}
function UploaderMgronStatus(opCode,fileSize,percent,serverPath,status) 文档收集自网络,仅用于个人学习
{
switch (status)
{
case 0:
break;
case 1:
uexWindow.closeToast();
uexUploaderMgr.closeUploader(opCode);
uexWindow.toast("0","5","上传头像成功!","3000");
break;
case 2:
uexWindow.closeToast();
uexWindow.toast('0','5',"上传失败",2000);
uexUploaderMgr.closeUploader(opCode);
break;
}
}
function UploaderMgrCreateUploaderCb(opCode,dataType,data){ 文档收集自网络,仅用于个人学习
if(data == 0){
var path = document.getElementById('pic').value;
uexUploaderMgr.onStatus = UploaderMgronStatus;
var inCompress = '3';
uexUploaderMgr.uploadFile(opCode,path,"upfile",inCompress); 文档收集自网络,仅用于个人学习
}else{
uexWindow.closeToast();
uexWindow.toast('0','5',"上传失败",2000);
}
}
function upload()
{
uexWidgetOne.cbError = uexWidgetOneErrorCb;
uexUploaderMgr.cbCreateUploader = UploaderMgrCreateUploaderCb; 文档收集自网络,仅用于个人学习
uexWindow.toast('1','5','正在上传...','');
uexUploaderMgr.createUploader('1',uploadHttp);
}