异常:The temporary upload location [/tmp/tomcat.135042057.80/work/Tomcat/localhost/ROOT] is not valid(

Posted 诡计的不老歌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了异常:The temporary upload location [/tmp/tomcat.135042057.80/work/Tomcat/localhost/ROOT] is not valid(相关的知识,希望对你有一定的参考价值。

方法一:

/**
* 文件上传临时路径 * 在Spring Boot下配置location,可以在main()方法所在文件中添加如下代码: */ @Bean MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); factory.setLocation("data/tmp"); return factory.createMultipartConfig(); }

 

注入一个Bean,手动配置临时目录,这个location可以理解为临时文件目录,我们可以通过配置location的值,使其指向我们的项目需要的临时文件的目录,该方法直接放在application.java文件中

 

解决办法二:
在 yml或properties配置文件 中添加:

server.tomcat.basedir: /data/tmp

 

方法三:修改代码直接从内存中获取

以上是关于异常:The temporary upload location [/tmp/tomcat.135042057.80/work/Tomcat/localhost/ROOT] is not valid(的主要内容,如果未能解决你的问题,请参考以下文章

记一次文件上传报错解决过程The temporary upload location is not vali

关于springboot上传文件报错:The temporary upload location ***is not valid

springboot放到linux启动报错:The temporary upload location [/tmp/tomcat.8524616412347407692.8111/work/

File upload error - unable to create a temporary file

Warning: File upload error - unable to create a temporary file in Unknown on line 0

Warning: File upload error - unable to create a temporary file in Unknown on line 0 的解决办法