Question

I have org.springframework.web.multipart.commons.CommonsMultipartFile object and i need to get absolute file path on client device. Thanks debugger screenshot

I need to show picture to user, without saving on server.

Was it helpful?

Solution

You are not allowed to get the full path of client device, maybe you can spy the user's username or OS what he dont like you to know.

Use FileApi from Javascript instead (How can I draw an image from the HTML5 File API on Canvas?).

OTHER TIPS

Most browsers will not include the path information on the client.

For example if you have a CommonsMultipartFile you can call getFileItem() to receive a FileItem and then from the FileItem call getName().

For example:

commonsMultipartFile.getFileItem().getName();

However as the documentation states:

Returns the original filename in the client's filesystem, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top