0

I want to know if this is even possible. One of my requirement is to allow users to upload images, generate new names for those images and rename the images with the new names in the folder from which they were uploaded.

I implemented the first part i.e uploading images based on this blog http://www.raistudies.com/spring/spring-mvc/file-upload-spring-mvc-annotation/

It works fine. But I am unable to find a way to read the location from where these images are uploaded. Usually users will map network drives on their local system and upload these images from those network drives. So I want to if its even possible to read the location.

Any input will be greatly appreciated.

Update: I tried using jquery to read the value in the input filed, but this just give me the image name and not the complete path. eg., C:/Images/OnLoc/abc.img gives me jsut abc.img but I want the complete path i.e C:/Images/OnLoc/abc.img

Thanks, Lakshmi

lakshmi
  • 355
  • 2
  • 7
  • 15
  • Looks like this is browser specific behaviour. Also see [this question on stackoverflow](http://stackoverflow.com/questions/1130560/get-full-path-of-a-file-with-fileupload-control/1130801#1130801). – user967058 Oct 04 '11 at 15:41

2 Answers2

1

It depends. If you are using CommonsMultipartFile, then the getOriginalFilename method might return path data in addition to the filename. As per the API docs:

This may contain path information depending on the browser used, but it typically will not with any other than Opera.

So the short answer is probably not.

atrain
  • 8,835
  • 1
  • 33
  • 39
  • I am using CommonsMultiPartFile but the getOriginalFileName jsut returns the name of the fle and not the complete path. Anyways thanks for the answer Aaron. – lakshmi Oct 04 '11 at 16:02
0

You can use JavaScript to store the location in an hidden field when user selects a file to upload and then when user will submit the form, get the value from form bean.

  • Rahul, I thought of that, but as I mentioned when I am reading the value of the field, it just gets the image name and not the entire location. – lakshmi Oct 04 '11 at 20:38