国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

成都集團(tuán)網(wǎng)站建設(shè)核酸檢測最新消息

成都集團(tuán)網(wǎng)站建設(shè),核酸檢測最新消息,培訓(xùn)機(jī)構(gòu)軟件開發(fā),網(wǎng)站開發(fā)經(jīng)營范圍之前在網(wǎng)上搜了好多教程,一直沒有找到合適自己的,要么只有前端部分沒有后端,要么就是寫的不是很明白。所以還得靠自己摸索出來后,來此記錄一下整個過程。 其實就是不要用默認(rèn)的 action,要手動實現(xiàn)上傳方式 http-reque…

之前在網(wǎng)上搜了好多教程,一直沒有找到合適自己的,要么只有前端部分沒有后端,要么就是寫的不是很明白。所以還得靠自己摸索出來后,來此記錄一下整個過程。

  • 其實就是不要用默認(rèn)的 action,要手動實現(xiàn)上傳方式?http-request,然后再傳給后端進(jìn)行各種操作了
    • 這里隱藏了文件展示列表
    • 展示了上傳文件的個數(shù)
    • 文件去重上傳
    • 也對上傳文件的格式做了限制
    • 在點(diǎn)擊創(chuàng)建的時候 progress 會隨著上傳進(jìn)度動態(tài)變化

環(huán)境安裝什么的就不講了,直接上代碼好吧,這個是樣式圖

這是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">拖拽 / 點(diǎn)擊上傳文件 ( 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">創(chuàng)建</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("任務(wù)創(chuàng)建成功")}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://aloenet.com.cn/news/35136.html

相關(guān)文章:

  • 信息造價網(wǎng)seo是啥
  • 工業(yè)設(shè)計招聘1688seo優(yōu)化是什么
  • 別的網(wǎng)站可以做彈幕網(wǎng)絡(luò)營銷ppt
  • 網(wǎng)站建設(shè)zb533公司網(wǎng)站首頁排名
  • 福建省建設(shè)工程職業(yè)注冊網(wǎng)站如何建造一個網(wǎng)站
  • 純手工建網(wǎng)站新東方英語線下培訓(xùn)學(xué)校
  • 安卓系統(tǒng)開發(fā)平臺搜索引擎優(yōu)化的技巧有哪些
  • 佛山網(wǎng)站設(shè)計多少錢而的跟地seo排名點(diǎn)擊軟件
  • 廣州網(wǎng)站開發(fā)企業(yè)網(wǎng)絡(luò)推廣的方法有哪些
  • 國內(nèi)做網(wǎng)站建設(shè)好的一起來看在線觀看免費(fèi)
  • wordpress的url電腦優(yōu)化軟件哪個好用
  • 做網(wǎng)站的貼吧網(wǎng)絡(luò)營銷的步驟
  • 代辦公司注冊靠譜嗎優(yōu)化大師 win10下載
  • 靠做網(wǎng)站可以賺錢么想要網(wǎng)站推廣版
  • 網(wǎng)站域名在哪買近一周的新聞大事熱點(diǎn)
  • 備案時暫時關(guān)閉網(wǎng)站交換鏈接營銷的典型案例
  • 有哪些做任務(wù)網(wǎng)站學(xué)好seo
  • 濱州網(wǎng)站建設(shè)公司本周時事新聞概要10條
  • 網(wǎng)站做鏈輪會被懲罰嗎公司網(wǎng)站推廣方法
  • wordpress 換域名 全站301重定向百度熱搜榜小說排名
  • png圖片可以做網(wǎng)站圖標(biāo)嗎建設(shè)網(wǎng)站需要多少錢
  • 河源城鄉(xiāng)規(guī)劃建設(shè)局網(wǎng)站軟文新聞發(fā)布網(wǎng)站
  • 動態(tài)網(wǎng)站開發(fā)參考資料google建站推廣
  • 自己建的網(wǎng)站可以用筆記本做服務(wù)器嗎sem專員
  • 泗洪網(wǎng)站設(shè)計公司ip域名查詢網(wǎng)站入口
  • 抖音代運(yùn)營排名seo公司排行
  • 主流網(wǎng)站風(fēng)格精品成品網(wǎng)站入口
  • 網(wǎng)站開發(fā)實訓(xùn)報告參考文獻(xiàn)國內(nèi)真正的永久免費(fèi)建站
  • 免費(fèi)看電影的網(wǎng)站是什么快速收錄網(wǎng)
  • 怎樣做網(wǎng)站開發(fā)搜索優(yōu)化seo