title: Uploading image files to a different server in Spring 3
body: <p>Folks, I have a question which may sound like it has been addressed before but its not!!</p>
  
  <p>I am trying to upload images from my D drive to a server using Spring MVC 3.
  But when i try to copy a file from Drive D to Drive C it works!!
  Eg:- Load an image from my <code>http://localhost:8080/loadImage</code> and browse for an image to load into <a href="http://q.someimagerepository.com/" rel="nofollow">http://q.someimagerepository.com/</a>
  Code:-</p>
  
  <pre><code>InputStream inputStream = null;
  OutputStream outputStream = null;
  inputStream = helloFile.getInputStream();
  outputStream = new FileOutputStream("http://q.someimagerepository.com/newImage");
  int readBytes = 0;
  byte[] buffer = new byte[10000];
  while ((readBytes = inputStream.read(buffer, 0, 10000)) != -1) {
  outputStream.write(buffer, 0, readBytes);
  }
  outputStream.close();
  inputStream.close();
  </code></pre>
  
  <p>Where helloFIle(CommonsMultipartFile file) is a file I am loading from the screen after I browse and select it.
  Do we have to send the file extension as well?</p>
  
  <p>I am not sure what I am doing wrong. I am getting an error like :- </p>
  
  <p><strong>(The filename, directory name, or volume label syntax is incorrect)</strong></p>
  
  <p>Please let me know the correct way of doing this.
  Also when I try copy a file from Drive D to Drive C, the following code works but not in the aforementioned scenario :-</p>
  
  <pre><code>//Correct approach in SPRING
  helloFile.transferTo(new File("C:/"));
  </code></pre>