加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP MVC框架skymvc支持多文件上传

发布时间:2020-12-12 21:33:04 所属栏目:PHP教程 来源:网络整理
导读:1.代码upload.ctrl.php public function construct(){ parent:: construct(); } public function onDefault(){ $this-smarty-display("upload/default.html"); } public function onUpload(){ $this-loadClass("upload"); //上传的文件目录 $this-upload-upl

1.代码upload.ctrl.php

public function construct(){
parent::
construct();
}

public function onDefault(){

$this->smarty->display("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);

}

}

?>

2.代码upload.html

{include file="head.html"}

{include file="header.html"}
<div class="main-body box960">
<form method="post" action="/index.php?m=upload&a=upload" enctype="multipart/form-data">
<div class="row">
<div class="btn-upload">
<i class="iconfont icon-upload">
上传文件
<div class="btn-upload-file">

上传结果

{include file="footer.html"}

3.PHP代码

}
}

/*
function uploadFinish(e){
var data=eval("("+e.target.responseText+")");
$("#uploading").hide()
if(data.error != '')
{
skyToast(data.msg);
}else
{
$("#imgShow").html("");
$("#imgurl").val(data.imgurl);
}
}

function uploadError(e) { // upload error
skyToast("上传出错了");
}
*/

以上就是本文的全部内容,希望对大家学习php程序设计有所帮助。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读