相思资源网 Design By www.200059.com
本文实例为大家分享了skymvc实现文件上传的具体代码,供大家参考,具体内容如下
1.代码upload.ctrl.php
<"upload/default.html"); } public function onUpload(){ $this->loadClass("upload"); //上传的文件目录 $this->upload->uploaddir="attach/my/"; //允许上传的文件大小 $this->upload->maxsize=4194304000; //是否上传图片 $this->upload->upimg=true; //设置允许上传的文件类型 $this->upload->sysallowtype=array('gif','jpg','bmp','png','jpeg','txt','mpeg','avi','rm','rmvb','wmv','flv','mp3','wav','wma','swf','doc','pdf','zip','tar','svg'); $this->upload->allowtype=$this->upload->sysallowtype; //根据Id存储 $this->upload->iddir=0; $data=$this->upload->uploadfile("upimg"); //print_r($data); echo json_encode($data); } } "htmlcode"><!doctype html> <html> {include file="head.html"} <body> {include file="header.html"} <div class="main-body box960"> <form method="post" action="/index.php" enctype="multipart/form-data"> <div class="row"> <div class="btn-upload"> <i class="iconfont icon-upload"></i> 上传文件 <div class="btn-upload-file"> <input type="file" id="upimg" name="upimg" multiple> </div> </div> </div> <div style="height:10px;"></div> <div class="row"> <input type="submit" class="btn" value="上传"> </div> </form> <h3>上传结果</h3> <div class="result" id="result"></div> </div> {include file="footer.html"} <style> .result{border:1px solid #ccc; padding:5px;} .result div{line-height:24px;} .result .e{color:#D58384;} .result .s{color:#59A42A;} </style> <script src="/UploadFiles/2021-04-02/skyupload.js">3.PHP代码
function skyUpload(upid,url,success,error,uploadProgress) { var vFD = new FormData(); var f= document.getElementById(upid).files; $("#"+upid+"loading").show(); for(var i=0;i<f.length;i++){ vFD.append('upimg', document.getElementById(upid).files[i]); var oXHR = new XMLHttpRequest(); oXHR.addEventListener('load', success, false); oXHR.addEventListener('error', error, false); if(uploadProgress!=undefined){ oXHR.upload.addEventListener("progress", uploadProgress, false); } oXHR.open('POST',url); oXHR.send(vFD); } } /* function uploadFinish(e){ var data=eval("("+e.target.responseText+")"); $("#uploading").hide() if(data.error != '') { skyToast(data.msg); }else { $("#imgShow").html("<img src='/"+data.imgurl+".100x100.jpg' width='100'>"); $("#imgurl").val(data.imgurl); } } function uploadError(e) { // upload error skyToast("上传出错了"); } */以上就是本文的全部内容,希望对大家学习php程序设计有所帮助。
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无PHP MVC框架skymvc支持多文件上传的评论...