您的位置:首页 > Web前端 > JavaScript

使用jspsmartupload组件以时间+文件类型的方式保存文件

2008-03-04 21:07 711 查看
int count=0;

// Initialization
mySmartUpload.initialize(pageContext);

// Upload
mySmartUpload.upload();

com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
String strExt = mySmartUpload.getFiles().getFile(0).getFileExt();
java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS");//取系统时间,精确到毫秒。
java.util.Date date = new java.util.Date();
String strTime = simpleDateFormat.format(date);
String strFileName = strTime + "." + strExt;
String FilePath = uploadpath+strFileName;//uploadpath为保存目录名。

try
{
//count = mySmartUpload.save(uploadpath);
myFile.saveAs(FilePath);
}
catch (Exception e)
{
out.println(e.toString());
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: