标签:style blog color io os ar sp 文件 div
js代码
1 function ajaxFileUpload() { 2 var loading=‘<li class="close loading" ><img id="loading" src="{weiwin::$staticFilePath}/style/img/nopic.png"/></li>‘; 3 $(‘#aaa‘).append(loading); 4 $(‘#loading‘).bind("click",function(){ 5 $(‘#openwinbg01‘).css("display","block"); 6 $(‘#openwin01‘).css("display","block"); 7 }); 8 $.ajaxFileUpload 9 ( 10 { 11 url: "./index.php?g=Wap&m=Junk&a=upload", //用于文件上传的服务器端请求地址 12 secureuri: false, //一般设置为false 13 fileElementId: ‘file1‘, //文件上传空间的id属性 <input type="file" id="file" name="file" /> 14 dataType: ‘json‘, //返回值类型 一般设置为json 15 success: function (data) //服务器成功响应处理函数 16 { 17 $(‘.loading‘).remove(); 18 //alert(111); 19 // var img=$(‘#imgio‘).val(); 20 var dlid=$(‘#io‘).val()*1; 21 //var img="<dl><img src=‘"+data+"‘ id=‘"+id+"‘/><button class=‘close‘>删</button></dl>"; 22 var img=‘<li data-role="img" class="close clo" id="‘+dlid+‘"><img src="‘+data+‘" class="img11"></li>‘; 23 $("#aaa").append(img); 24 var io=$(‘#io‘).val()*1+1; 25 $("#io").attr(‘value‘,io); 26 27 }, 28 error: function (data, status, e)//服务器响应失败处理函数 29 { 30 alert(e); 31 }, 32 complete :function(){ 33 34 $(‘.clo‘).bind("click",function(){ 35 $(‘#openwinbg‘).css("display","block"); 36 $(‘#openwin‘).css("display","block"); 37 var ii = $(this).attr(‘id‘)*1+1; 38 //alert(ii); 39 $(‘#ii‘).attr(‘value‘,ii); 40 }); 41 } 42 } 43 ) 44 return false; 45 }
html代码
1 <input type="file" capture="camera" class="input-file" name="file1" id="file1" onchange="ajaxFileUpload()" />
thinkphp后天代码
1 //文件上传 2 public function upload(){ 3 import("@.ORG.UploadFile"); 4 $upload = new UploadFile();// 实例化上传类 5 $upload->maxSize = 31457280000;// 设置附件上传大小 6 //$upload->allowExts = array(‘jpg‘, ‘gif‘, ‘png‘, ‘jpeg‘);// 设置附件上传类型 7 $upload->savePath = ‘./Uploads/file/‘.date(‘ymd‘).‘/‘;// 设置附件上传目录 8 $upload->imageClassPath = ‘@.ORG.Image‘; 9 //设置需要生成缩略图,仅对图像文件有效 10 $upload->thumb = true; 11 //设置需要生成缩略图的文件后缀 12 $upload->thumbPrefix = ‘m_‘; //生产2张缩略图 13 //设置缩略图最大宽度 14 $upload->thumbMaxWidth = ‘480‘; 15 //设置缩略图最大高度 16 $upload->thumbMaxHeight = ‘320‘; 17 if(!$upload->upload()) {// 上传错误提示错误信息 18 echo 0; 19 }else{ 20 $info=$upload->getUploadFileInfo(); 21 echo $upload->savePath.‘m_‘.$info[0][‘savename‘]; 22 } 23 }
标签:style blog color io os ar sp 文件 div
原文地址:http://www.cnblogs.com/guanye286478645/p/4029530.html