title: How to upload image in my project folder in spring mvc?
body: <p>I'm trying to upload an image to my project folder.
  My project's structure is:</p>
  
  <blockquote>
    <p>ProjectName->WebContent->WEB-INF->resources</p>
  </blockquote>
  
  <p>In my <code>spring-dispatcher-servlet.xml</code> I added:</p>
  
  <pre><code>&lt;mvc:resources mapping="/resources/**" location="/resources/"
      cache-period="31556926"/&gt;
  &lt;mvc:annotation-driven/&gt;
  </code></pre>
  
  <p>Now, in my controller, I uploaded the image using:</p>
  
  <pre><code>File path = new File("/home/bmshamsnahid/Tomcat Server/apache-tomcat-7.0.69/webapps/ROOT/WEB-INF/uploads");
  if (!path.exists()) boolean status = path.mkdirs();
  File uploadedFile = new File(path + "/" + fileName);
  item.write(uploadedFile);
  </code></pre>
  
  <p>Then the image can be found in  <code>/home/bmshamsnahid/Tomcat Server/apache-tomcat-7.0.69/webapps/ROOT/WEB-INF/uploads</code>, but if I use:</p>
  
  <pre><code>File path = new File("/resources");
  </code></pre>
  
  <p>Then it says it couldn't find that directory.</p>
  
  <p>So, how do I upload an image to the <code>Project-&gt;WebContent-&gt;WEB-INF-&gt;resources</code> folder?</p>
  
  <p>I don't use any dependency managers.</p>