通过几个课时的学习,我依靠同学的帮助、网上查阅相关资料。终于完成老师分配的上传下载任务。
从中我整理出几个比较重要的知识点:
1.敲代码之前,需要先引入配置文件:
2
|
bootstrap-fileinput/css/fileinput.min.css
bootstrap-fileinput/js/fileinput.min.js
|
2.考虑到显示结果需要中文化,所以要引入
1
|
bootstrap-fileinput/js/fileinput_locale_zh.js
|
3.模态窗口的弹出
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" myModalLabel()>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
填写学生个人信息
</h4>
</div>
<div class="modal-body">
<div class="am-g">
<form class="am-form am-form-horizontal" action="__URL__/add" method="post" style="padding-top: 30px;" id="form">
<input value="504" name="roleId" type="hidden">
<div class="am-form-group">
<label for="user-name" class="am-u-sm-3 am-form-label">
学号
</label>
<div class="am-u-sm-9">
<input id="roleName" required="" placeholder="请输入学号" value="{$data.no}" name="no" type="text">
<small id="helpRole">输入学号</small>
</div>
</div>
<div class="am-form-group">
<label for="user-name" class="am-u-sm-3 am-form-label">
姓名
</label>
<div class="am-u-sm-9">
<input id="roleName" required="" placeholder="请输入姓名" value="{$data.name}" name="name" type="text">
<small id="helpRole">输入姓名。</small>
</div>
</div>
4.后台的运行代码“
public function upload(){
if(IS_GET){
$this->display();
exit;
}
$upload= new \Think\Upload();
$upload->maxSize=0;
$upload->exts=array('csv');
$upload->rootPath='./Public/Upload/';
$upload->savePath='';
//上传文件
$info=$upload->upload();
if(!$info){
$this->error($upload->getError());
}else{
$this->import($upload->rootPath.$info['file']['savepath'].$info['file']['savename']);
}
}
2
|
bootstrap-fileinput/css/fileinput.min.css
bootstrap-fileinput/js/fileinput.min.js
|