免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
成功element ui el-upload上傳文件

<template>

  <div class="app-container">

    <el-form ref="form" :model="form" :rules="rules2label-width="120px">

      <el-upload

        class="upload-demo"

        action="http://localhost:12345/api/test/upload"

        accept=".pdf"

        multiple

        :limit="1"

        :on-exceed="handleExceed"

        :file-list="fileList"

      >

        <el-button size="small" type="primary">點(diǎn)擊上傳</el-button>

        <div slot="tip" class="el-upload__tip">只能上傳pdf文件,且不超過10M</div>

      </el-upload>

    </el-form>

  </div>

</template>

<script>

export default {

  data() {

    return {

      fileList: [],

      form: {},

    };

  },

  methods: {

    handleExceed(filesfileList) {

      this.$message.warning(

        `當(dāng)前限制選擇個(gè)文件,本次選擇了 ${files.length} 個(gè)文件,共選擇了 ${

          files.length + fileList.length

        } 個(gè)文件`

      );

    },

  },

};

</script>

<style scoped>

.line {

  text-aligncenter;

}

</style>

后臺(tái)core api接口

[HttpPost("upload")]

        public async Task<IpResponse> upload(IFormFile file)

        {

            var path = Directory.GetCurrentDirectory();

            var currentDate = DateTime.Now;

            string webRootPath = Directory.GetCurrentDirectory();

            try

            {

                var filePath = $"/UploadFile/{currentDate:yyyyMMdd}/";

                //創(chuàng)建每日存儲(chǔ)文件夾

                if (!Directory.Exists(webRootPath + filePath))

                {

                    Directory.CreateDirectory(webRootPath + filePath);

                }

                if (file != null)

                {

                    //文件后綴

                    var fileExtension = Path.GetExtension(file.FileName);//獲取文件格式,拓展名

                    //判斷文件大小

                    var fileSize = file.Length;

                    if (fileSize > 1024 * 1024 * 10) //10M TODO:(1mb=1024X1024b)

                    {

                        return IpResponse.Create(true, "0", "上傳的文件不能大于10M");

                    }

                    //保存的文件名稱(以名稱和保存時(shí)間命名)

                    var saveName = file.FileName.Substring(0, file.FileName.LastIndexOf('.')) + fileExtension;

                    //文件保存

                    using (var fs = System.IO.File.Create(webRootPath + filePath + saveName))

                    {

                        file.CopyTo(fs);

                        fs.Flush();

                    }

                    //完整的文件路徑

                    var completeFilePath = Path.Combine(filePath, saveName);

                    return IpResponse.Create(true, "0", "上傳成功");

                }

                else

                {

                    return IpResponse.Create(true, "0", "上傳失敗,未檢測(cè)上傳的文件信息");

                }

            }

            catch (Exception ex)

            {

                return IpResponse.Create(true, "0", "文件保存失敗,異常信息為:" + ex.Message);

            }

        }

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Element+vue.js 實(shí)現(xiàn)文件模板下載,和Upload 上傳文件帶參數(shù)
element upload 上傳報(bào)錯(cuò) Uncaught TypeError: Cannot set property 'status' of undefined
delphi 獲取一個(gè)文件夾下的所有文件
QT讀取文件夾下的特定文件_qt打開文件夾路徑并讀取文件
百度 flash html5自切換 多文件異步上傳控件webuploader基本用法
C# 文件上傳類
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服