上传、下载

上传

配置支持的后缀

# 上传相关
UPLOAD_SIZE = 100
UPLOAD_EXT = jpg,jpeg,png,gif,bmp,doc,docs,xls,xlsx,pdf,ppt,video,mp4,mp3,webm

element ui 上传

<el-upload style="margin-left:10px;"
  accept="<?=lib\Mime::get('video,mp4,mp3,webm')?>"
  class="none"
  action="/admin/media/upload" 
  :on-success="(response, file, fileList) => {
    return video_success(response, file, fileList, scope.row);
  }"  >
  <el-button size="small" type="primary">上传</el-button> 
</el-upload>

下载

远程下载限制mime

add_action("allow_mime",function(&$mime){
    $mime[] = "webm";
    $mime[] = "video";
    $mime[] = "mp4";
    $mime[] = "mp3";
});

默认可下载的文件

['jpg','jpeg','png','gif','pdf','xls','xlsx','doc','docx','ppt','pptx']

调用

download_file_safe($url, $mimes = ['image/*','video/*'], $cons = [], $contain_http = false)

uniapp

<cl-upload :headers="upload_header" v-model="form.file" :action="upload_url"></cl-upload>

upload_url:'',
upload_header:{}

this.upload_url = this.config.upload_url
this.upload_header = this.get_header()