Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to change the File name before uploading it.

 
Kalpesh Desai
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jimi,
Thanks a lot for your suggestion
Regards,
Kalpesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic