Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to rename and upload a file?  RSS feed

 
pranjal mishra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I m working on a module in which i have to upload an image, create its thumbnails and then display it. I m using struts2 copyFile() method for this. In the normal case everything is working perfect. Now I want to rename the actual file with the datetime stamp and then upload it so that i can distinguish two files. Here is the method i m using for it.

You can see in the code i m using two variables uploadedDateTime for the time stamp thing & uploadFileExt which returns the file extension.
Now suppose if i m uploading a file abc.jpg from any location i want to rename it with uploadedDateTime.jpg and then upload it.
Now as the code show, I m also deleting the original file and leaving only two thumbnails on the system.
So I need suggestions or help. Mean while I m also trying & if i'll find any solutions i'll update it.
Thanks
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out http://faq.javaranch.com/java/FileUpload?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!