后台的AJAX上传 封装的上传函数 想不同的功能上传到不同的文件夹
所以需要在添加或者编辑页面增加额外的参数 告诉upload函数
直接来吧
1 add.html
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Coursename')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-act_name" class="form-control" name="row[course_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Chapter')}:</label>
<div class="col-xs-12 col-sm-8">
{:build_select('row[chapter_id]', $chapterdata, null, ['class'=>'form-control', 'required'=>''])}
</div>
</div>
<div class="form-group">
<label for="c-video_url" class="control-label col-xs-12 col-sm-2">{:__('Coursevideo')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-video_url" data-url='ajax/uploadvideo' data-rule="" class="form-control" size="50" name="row[course_video]" type="text" >
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-video_url" class="btn btn-danger plupload" data-multipart={"folder":"online_course_video"} data-input-id="c-video_url" data-mimetype="mp4,avi,ogg" data-multiple="false" data-preview-id="p-video_url"><i class="fa fa-upload"></i>{:__('Upload')}</button></span>
</div>
<span class="msg-box n-right" for="c-video_url"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-video_url"></ul>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
红色部分是关键
那么后端的代码是怎么获取的呢 其实很简单 和普通的变量获取一样
//获取上传到哪个文件夹
$folder=$this->request->post('folder');
来源:oschina
链接:https://my.oschina.net/u/4406565/blog/4290681