title: Understanding MultipartFile transferTo() method in Spring MVC
body: <p>I am using Spring Framework's MultipartFile to allow a user to upload a picture to a profile. I've configured DispatcherServlet in a servlet initializer class that extends AbstractAnnotationConfigDispatcherServletInitializer. In that class, I've overridden the customizeRegistration() method as follows:</p>
  
  <pre><code>@Override
  protected void customizeRegistration(Dynamic registration) {
      registration.setMultipartConfig(new MultipartConfigElement("/tmp/practicewellness/uploads", 2097152, 4194304, 0));
  }
  </code></pre>
  
  <p>The MultipartFile's transferTo() method calls for a file location in the filesystem where the uploaded file will be written temporarily. Can this location be anywhere? When I used the following location in the method:</p>
  
  <pre><code>profilePicture.transferTo(new File("tmp/practicewellness/" + employee.getUsername() + ".jpg"));
  </code></pre>
  
  <p>... I get the following error:</p>
  
  <pre><code>Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\Users\kyle\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\work\Catalina\localhost\practicewellness\tmp\practicewellness\uploads] is not valid
  </code></pre>
  
  <p>So I can see that it's looking for this file location deep inside one of my Eclipse plugins. I don't understand why it looks there. When I look there, the "tmp" directory is not there. But regardless, is it okay for me to go into that plugin and create the directory there? Or is there a better way to smooth this out? </p>