/**
*
* @param upload
* @param uploadFileName
* @return 上传多个附件
* @throws Exception
*/
public String fileUpload(File[] upload, String[] uploadFileName)
throws Exception {
StringBuffer attachmentIds = new StringBuffer();
if (upload != null) {
String savepath = "";//上传路径
File dirPath = new File(savepath);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
FileOutputStream fos = null;
FileInputStream fis = null;
String saveFileName = null;
String suffix = null;//文件格式
for (int i = 0; i < upload.length; i++) {
int index = uploadFileName[i].lastIndexOf(".");
String fileName = uploadFileName[i];
if (index != -1) {
suffix = fileName.substring(index + 1, fileName.length());
}
saveFileName = String.valueOf((new java.util.Date()).getTime())//保存的文件名
+ "." + suffix;
fos = new FileOutputStream(savepath + saveFileName);
fis = new FileInputStream(upload[i]);
byte[] buffer = new byte[BUFFER_SIZE];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
}
fos.close();// 注意:流应当关闭。
fis.close();
}
return savepath+saveFileName;
}