当前位置: 首页 > news >正文

成都集团网站建设广州网站优化多少钱

成都集团网站建设,广州网站优化多少钱,网站建设 方案 评价表,中国建设银行官网主页之前在网上搜了好多教程,一直没有找到合适自己的,要么只有前端部分没有后端,要么就是写的不是很明白。所以还得靠自己摸索出来后,来此记录一下整个过程。 其实就是不要用默认的 action,要手动实现上传方式 http-reque…

之前在网上搜了好多教程,一直没有找到合适自己的,要么只有前端部分没有后端,要么就是写的不是很明白。所以还得靠自己摸索出来后,来此记录一下整个过程。

  • 其实就是不要用默认的 action,要手动实现上传方式 http-request,然后再传给后端进行各种操作了
    • 这里隐藏了文件展示列表
    • 展示了上传文件的个数
    • 文件去重上传
    • 也对上传文件的格式做了限制
    • 在点击创建的时候 progress 会随着上传进度动态变化

环境安装什么的就不讲了,直接上代码好吧,这个是样式图

这是vue3代码

<template><el-upload class="upload-demo form-item" v-model:file-list="fileList" drag multiple :http-request="httpRequest" :show-file-list="false" auto-upload="false" :accept=upload_accept><el-icon class="el-icon--upload"><upload-filled /></el-icon><div class="el-upload__text">拖拽 / 点击上传文件 ( zip, jpg, png ……)</div><template #tip><div class="el-upload__tip">已上传 {{ fileListLength }} 个文件</div></template></el-upload><el-progress :percentage="progress.curr" :color="progress.color" /><el-button type="info" class="btn" @click="removeFile">清空文件</el-button><el-button type="primary" class="btn" @click="create">创建</el-button>
</template><script setup lang="ts">
import { ref, watch } from "vue";
import http from "@/utils/axios/index";
import { UploadFilled } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';const public_elmsg_success = (msg: string) => {ElMessage({ type: 'success', duration: 1000, showClose: true, message: msg })
};const public_elmsg_warning = (msg: string) => {ElMessage({ type: 'warning', duration: 1000, showClose: true, message: msg })
};const public_elmsg_error = (msg: string) => {ElMessage({ type: 'error', duration: 1000, showClose: true, message: msg })
};const upload_accept = ref(".JPG,.PNG,.JPEG,.PCD,.MP4,.AVI,.DAT,.DVR,.VCD,.MOV,.SVCD,.VOB,.DVD,.DVTR,.DVR,.BBC,.EVD,.FLV,.RMVB,.WMV,.MKV,.3GP,.ZIP"); // 限制了上传文件的格式 大写后缀
const upload_lower = ref(upload_accept.value.split(',').map((item: any) => item.toLowerCase())); // 限制上传文件的格式 小写后缀
const fileList: any = ref([]);
const fileList1: any = ref([]);
const fileListLength = ref(0);const progress = ref({ "curr": 0, "color": "orange" })watch(fileList1, (newVal, oldVal) => {console.log(newVal, oldVal)fileListLength.value = newVal.value;fileListLength.value = newVal.length;
}, { immediate: true, deep: true });const httpRequest = (options: any) => {let nameList: Array<any> = [];fileList1.value.forEach((item: any) => {nameList.push(item.name);});const file_suffix = options.file.name.split(".");if (!upload_lower.value.includes(`.${file_suffix[file_suffix.length - 1]}`)) {public_elmsg_warning(`文件 ${options.file.name} 格式不正确`);return;}if (nameList.includes(options.file.name)) { }else {fileList1.value.push(options.file)}fileList.value = fileList1.value;
}const removeFile = () => {fileList.value = [];fileList1.value = [];progress.value.curr = 0;
}const create = () => {const formData = new FormData()fileList1.value.forEach((file: any) => {console.log(file)formData.append('files', file)})http.post("task/create/", formData, {headers: { "Content-Type": "multipart/form-data" }, onUploadProgress(progressEvent: any) {progress.value.curr = Math.round((progressEvent.loaded * 100) / progressEvent.total)if (progress.value.curr == 100) { progress.value.color = 'green' }else { progress.value.color = 'orange' }},}).then((res: any) => {if (res.code == 0) {public_elmsg_success("任务创建成功")}else { public_elmsg_error(res.msg) }});
}
</script>

v3版本的 djagno 代码

from loguru import logger
from django.http.response import JsonResponse
from django.views.decorators.csrf import csrf_exempt@csrf_exemptdef create_task(request):files = request.FILES.getlist('files')for fit in files:logger.info(f"name: {fit.name} size: {round(fit.size/ 1024 / 1024 / 1024, 5)} G")# 保存文件#  with open(f"{os.sep.join(['.', fit['name']])}", mode="wb") as f:#         f.write(fit)return JsonResponse({"code": 0, "msg": "success"})
http://www.mmbaike.com/news/106241.html

相关文章:

  • 网站建设销售兼职合同青岛seo网站关键词优化
  • 有赞可以做独立网站吗杭州产品推广服务公司
  • 四博互联做的网站免费营销软件网站
  • 从哪里找网站网站建设 全网营销
  • 微软雅黑做网站某个网站seo分析实例
  • 做解析视频网站违法莫中国国家人事人才培训网证书查询
  • 城阳网站建设培训谷歌搜索引擎免费入口 香港
  • php网站模块网站收录查询爱站
  • 做网站一般要多钱2023智慧树网络营销答案
  • 男女做暖暖的免费观看网站深圳网络推广推荐
  • wordpress 本地写文章aso优化前景
  • 如何查询网站死链二级域名注册平台
  • 基层政府网站集约化建设报告北京做网络优化的公司
  • 阀门行业网站怎么做本网站三天换一次域名
  • 昆明网站建设教学视频今日重庆重要消息
  • 开州网站建设app排名优化
  • 自建购物网站多少钱如何提高自己的营销能力
  • 乌鲁木齐哪里有做网站的公司单页网站seo优化
  • 上传自己做的网站后台怎么办影视后期培训班一般要多少钱
  • 保定建设网站关键词优化外包
  • 做国外网站衣服码数要怎么写中山seo排名
  • 大连网站开发培训班seo常用工具网站
  • 珠海网站建设小程序上海疫情突然消失的原因
  • 做二手房网站有哪些大连今日新闻头条
  • 太平洋建设网站龙华线上推广
  • 网站排名权重怎么做seo优化包括什么
  • 临漳网站制作网络促销的方法有哪些
  • 网站建设的推进方案刷关键词排名软件有用吗
  • 做网站的网址怎么弄金戈枸橼酸西地那非片
  • 专业网网站建设新产品推广方案策划