zoukankan      html  css  js  c++  java
  • 上传--spring-boot

       <dependency>
       <groupId>commons-fileupload</groupId>
       <artifactId>commons-fileupload</artifactId>
       <version>1.3.1</version>
      </dependency>

    @RequestMapping(value = "/upload/", method = RequestMethod.POST)
        @ResponseBody 
        public String upload(
               @RequestParam("file") MultipartFile  upfile,
               HttpServletRequest req) throws IOException {
    
           String path ="D:\study\";
           String imageName =upfile.getOriginalFilename();
           // |获取输入流
           InputStream is = upfile.getInputStream();
           // |文件输出流
           //OutputStream os = new FileOutputStream(new File(path,upfile.getOriginalFilename()));
           OutputStream os = new FileOutputStream(new File(path,imageName));
           System.out.println("come0");
           // |循环写入
           int length = 0;
           byte[] buffer = new byte[128];
           while ((length = is.read(buffer)) != -1) {
               os.write(buffer, 0, length);
           }
           System.out.println("come1");
           is.close();
           os.close();
           System.out.println("come2");
           
           return imageName;
       }
  • 相关阅读:
    AssetBundleNote
    UNet笔记
    HololensAR开发设置
    Hololens真机使用Unity开发流程
    数据结构笔记
    解决粘包问题
    使用C#中的Socket进行通讯
    解决Sql注入,防止恶意数据
    110. 平衡二叉树
    104.二叉树的最大深度
  • 原文地址:https://www.cnblogs.com/cnchengv/p/8426482.html
Copyright © 2011-2022 走看看