指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

form表单上传的时候获取file对象的方法:

我有如下vue3的upload方法
const upload = (newFiles: File[] | null) => {
  if (!newFiles || newFiles.length === 0) {
    return;
  }

  const uploadedFile = newFiles[0];
  const formData = new FormData();
  formData.append("file", uploadedFile);

  console.log("formData is:", formData) // 打印出来为空
  console.log('file: ', formData.get('file')); // 可以打印出数据,这个很重要
}