appcan拍照,选取照片,上传
1 <div onclick="actionsheet(0)”>照片1</div> 2 <div onclick="actionsheet(1)“>照片2</div> 3 <div onclick="onclick="fuiimg()">上传</div> 4 <script> 5 //定义变量 6 var imgurl = "";//默认图片地址 7 var iurl = new Array(); 8 iurl[0]="";//图片1 9 iurl[1]="";//图片2 10 var sunt=0;//图片菜单选择返回的索引号 11 var uploadHttp = "http://192.168.1.191/H.ashx"; 12 </script> 13 <script> 14 zy_init(); 15 window.uexOnload=function(type){ 16 if(!type){ 17 uexWindow.setBounce("1"); 18 uexWindow.showBounceView("0","#FFF","0"); 19 uexWindow.showBounceView("1","#FFF","0"); 20 } 21 } 22 </script> 23 <script> 24 window.uexOnload = function() 25 { 26 //****************照片菜单回调*************** 27 uexWindow.cbActionSheet = function(opId, dataType, data){ 28 switch (parseInt(data)) { 29 case 0: 30 uexCamera.open(); 31 break; 32 case 1: 33 uexImageBrowser.pick(); 34 break; 35 } 36 } 37 //****************拍照回调*************** 38 uexCamera.cbOpen = function(opId,dataType,data){ 39 if(dataType==0) 40 { 41 imgurl = data; 42 switch(sunt){ 43 case 0: 44 iurl[0]=imgurl; 45 break; 46 case 1: 47 iurl[1]=imgurl; 48 break; 49 } 50 } 51 } 52 //****************选择图片回调*************** 53 uexImageBrowser.cbPick = function(opId,dataType,data) 54 { 55 if(dataType==0){ 56 imgurl = data; 57 switch(sunt){ 58 case 0: 59 iurl[0]=imgurl; 60 break; 61 case 1: 62 iurl[1]=imgurl; 63 break; 64 } 65 } 66 } 67 68 //****************************************** 69 } 70 71 </script> 72 <script> 73 74 //上传图片 75 function fuiimg() 76 { 77 uexXmlHttpMgr.onData=function(inOpCode,inStauts,inResult){ 78 if(inStauts==1){ 79 alert(inResult); 80 uexXmlHttpMgr.close("1"); 81 document.getElementById('ann2').innerText="полный"; 82 } 83 } 84 85 uexXmlHttpMgr.open("1","post",uploadHttp,30000); 86 if(iurl[0]!="") 87 { 88 uexXmlHttpMgr.setPostData("1","1","filename1",iurl[0]); 89 } 90 if(iurl[1]!="") 91 { 92 uexXmlHttpMgr.setPostData("1","1","filename2",iurl[1]); 93 } 94 uexXmlHttpMgr.send("1"); 95 96 } 97 //弹出actionSheet 98 function actionsheet(id) 99 { 100 sunt=id; 101 uexWindow.actionSheet("选择图片", "取消", ["照相机拍摄","本地文件"]); 102 } 103 104 105 </script>
服务端ashx
1 if (context.Request.Files["filename1"] != null) 2 { 3 string fileName = Path.GetFileName(context.Request.Files["filename1"].FileName); 4 string end = fileName.Substring(fileName.Length - 4).ToLower(); 5 6 7 if (end.Equals(".jpg") || end.Equals(".png") || end.Equals(".gif")) 8 { 9 context.Request.Files["filename1"].SaveAs(ljstr + "\\" + id + "_" + fileName); 10 img01 = DateTime.Now.ToString("yyyyMMdd") + "/" + id + "_" + fileName; 11 } 12 }
在线打包时选取 uexImageBrowser,uexCamera,uexXmlHttpMgr 这几个插件功能才能好使