Java cannot get file when uploading a file.

based on the framework of DUBBO,SSM and easyui, I wrote a function of uploading pictures, uploading and sharing music, and now I can"t get that file

tomcat

in controller.
<form id="upload_form" enctype="multipart/form-data" action="/shop/upload_deal" method="post">
  <input class="easyui-filebox" style="width:300px" data-options="onChange:change_photo" type="file" id="file_upload" name="file"/><br/>
  <input type="submit" value="" /> <br/>
</form>

  String filePath = request.getSession().getServletContext()
                .getRealPath("/") + "upload/" + multipartFilefile.getOriginalFilename();
        System.out.println(filePath);
        File saveDir = new File(filePath);

        ImageUtils.ImageUpload(saveDir);//File

did I write something wrong, or I would like to ask where I put the picture when I submitted the picture and passed it to controller from the front end?

Mar.10,2021

first check whether the frontend has obtained the address of the image. If so, then check whether the address is obtained when receiving it at the backend, and then check whether it is the problem of the frontend or the backend


if the controller does not receive the file, please check whether the configuration is correct
if the controller receives the file, please check whether there is a upload folder under the target package.
after your project is released, the files are all saved in the target package


try to change the request parameters in Controller MultiparFile miltiparFilefile to MultiparFile file

.
Menu