title: How to display a local image (saved on C disk) using Spring?
body: <p>So, I am currently developing a Spring web application that lets you upload an image (valid extensions are: .png, .jpeg, .jpg and .gif) from a form. The image is then saved on a disk and its relative path is stored in a database. I have successfully saved the image to a disk using this code:</p>
  
  <pre><code>@Override
  public void saveThumbnail(MultipartFile thumbnailFile) throws Exception {
      String folder = "/bundles/";
      byte[] bytes = thumbnailFile.getBytes();
      Path path = Paths.get(folder + thumbnailFile.getOriginalFilename());
      Files.write(path, bytes);
  }
  </code></pre>
  
  <p>The form looks like that</p>
  
  <p><a href="https://i.stack.imgur.com/qXco1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qXco1.png" alt="enter image description here"></a></p>
  
  <p>And here's the code that displays this form</p>
  
  <pre><code>                &lt;form:form method="POST" modelAttribute="eventForm" class="form-signin" enctype="multipart/form-data"&gt;
                  &lt;spring:bind path="name"&gt;
                      &lt;span&gt;Name&lt;/span&gt;&lt;br&gt;
                      &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                          &lt;form:input type="text" path="name" class="form-control" placeholder="Name"
                                      autofocus="true"&gt;&lt;/form:input&gt;
                          &lt;form:errors path="name"&gt;&lt;/form:errors&gt;
                      &lt;/div&gt;
                  &lt;/spring:bind&gt;
  
                  &lt;spring:bind path="price"&gt;
                      &lt;span&gt;Price&lt;/span&gt;&lt;br&gt;
                      &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                          &lt;form:input type="number" path="price" class="form-control"&gt;&lt;/form:input&gt;
                          &lt;form:errors path="price"&gt;&lt;/form:errors&gt;
                      &lt;/div&gt;
                  &lt;/spring:bind&gt;
  
                  &lt;spring:bind path="thumbnailFile"&gt;
                      &lt;span&gt;Thumbnail image&lt;/span&gt;&lt;br&gt;
                      &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                          &lt;c:if test="${eventForm.thumbnailUrl != null}"&gt;
                              &lt;img src="file:C:${eventForm.thumbnailUrl}"&gt;
                          &lt;/c:if&gt;
                          &lt;form:input type="file" path="thumbnailFile" class="form-control" name="thumbnailFile"/&gt;
                          &lt;form:errors path="thumbnailFile"&gt;&lt;/form:errors&gt;
                      &lt;/div&gt;
                  &lt;/spring:bind&gt;
  
                  &lt;spring:bind path="description"&gt;
                      &lt;span&gt;Description&lt;/span&gt;&lt;br&gt;
                      &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                          &lt;form:textarea rows="4" path="description" class="form-control" placeholder="Description"/&gt;
                          &lt;form:errors path="description"&gt;&lt;/form:errors&gt;
                      &lt;/div&gt;
                  &lt;/spring:bind&gt;
  
                  &lt;button type="submit" class="btn-add-new"&gt;Save&lt;/button&gt;
              &lt;/form:form&gt;
  </code></pre>
  
  <p>I have already tried to display it like that:</p>
  
  <pre><code>&lt;img src="file:C:${eventForm.thumbnailUrl}"&gt;
  </code></pre>
  
  <p>However, my browser seems to block this action in order to prevent any security problems. I did some research and found out that you can let Apache serve files from a directory that it can access. Since I am new to web development, I have no idea how I would implement that even though I looked up a few articles and tutorials.</p>
  
  <p>Thank you in advance.</p>