這就是我目前爲止的內容。我知道該文件的作品,因爲當我強制擴展名爲.jpg並上傳.jpg圖片時,它工作正常。但是文件名與附加的.jpg類似。在struts 2中上傳文件會產生擴展名爲.tmp的文件
E:\的Documents and Settings \ mgrif002 \桌面\ DATA \ upload_59fef24e_1302d1a3fb9__7ff5_00000001.tmp.jpg
try
{
String filePath = "E:/Documents and Settings/mgrif002/Desktop/data/";
//System.out.println("Server path:" + filePath);
System.out.println(form.getFile().getAbsolutePath());
File fileToCreate = new File(filePath,form.getFile().getAbsolutePath()+".jpg");
FileUtils.copyFile(form.getFile(), fileToCreate);
Dicom dicom_file = new Dicom(pid,fileToCreate.getAbsolutePath(), form.getName(),true,((short)1));
ccr.saveDicom(dicom_file);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
哇,這是可笑的簡單。謝謝! – 2011-05-26 17:51:52