aspose file tools*
The moose likes Servlets and the fly likes How to change the File name before uploading it. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to change the File name before uploading it." Watch "How to change the File name before uploading it." New topic
Author

How to change the File name before uploading it.

Kalpesh Desai
Greenhorn

Joined: Jul 23, 2001
Posts: 4
Hi ,
I'm using the Oreilly MultipartRequest class to upload the file using JSP from client machine to the server.
I need to change (rename)the file name before uploading it so that the file gets uploaded on server with this new name.
Can anyone help me by a suggestion on how to achieve this.
Thanks in advance,
Kalpesh
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
You will need to change the file name once the file has been uploaded onto the server as the "sandbox" security model prevents you from doing much on the client side.
If you really wanted to achieve this at the client side, you would have to research signed applets and JavaScript whereby you give the client code greater privileges for doing that sort of thing.
(Best to stick with renaming the file at the server side).
James.
Jimi Rock
Ranch Hand

Joined: Feb 19, 2001
Posts: 134
I had the same problem while working in a file uploading application. I also think that it is better to change the file name on the server side.
also, if it is preffered to be changed on the client side for such a reason, the job will be critical some how. you need to create another "temporal" file with the new name, if u dont want to change the one that already exists on the client machine. then upload that tomporal file to the server side. after that, it is better to delete it on the client side such that the user is not going to notice any changes on his/her file system.
any way, it is much more better to do it on the server side.
Regards,
MAC.
Kalpesh Desai
Greenhorn

Joined: Jul 23, 2001
Posts: 4
Thanks James,
I changed the filename at the server after uploading.
It worked for me.
Regards,
Kalpesh
Originally posted by james swan:
You will need to change the file name once the file has been uploaded onto the server as the "sandbox" security model prevents you from doing much on the client side.
If you really wanted to achieve this at the client side, you would have to research signed applets and JavaScript whereby you give the client code greater privileges for doing that sort of thing.
(Best to stick with renaming the file at the server side).
James.

Kalpesh Desai
Greenhorn

Joined: Jul 23, 2001
Posts: 4
Thanks Jimi,
Thanks a lot for your suggestion
Regards,
Kalpesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change the File name before uploading it.