开发者

Reading the location from where the image is uploaded

开发者 https://www.devze.com 2023-04-10 20:02 出处:网络
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

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 thes开发者_高级运维e 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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消