byte[] buf = new byte[1024];
int len = 0;
BufferedOutputStream bos = new BufferedOutputStream(sgetOutputStream);
while((len = bisread(buf))!=-1){
boswrite(buf,0,len);
bosflush();
}
思路是这样的了。。。具体你自己写吧。public class UploadAction extends ActionSupport {
private static final long serialVersionUID = -6707209240028419956L;
private File uploadify;
private String sclx;//1邮件
private String uploadifyFileName;
private static final DateFormat df = new SimpleDateFormat("yyyyMMddHHmm");
@Autowired
private WenjdetailManager wenjdetailManager;
public String uploadFile() throws Exception {
String extName = "";// 扩展名
String newFileName = "";// 新文件名
String nowTime = dfformat(new Date());// 当前时间
String random = "-" + (Mathround(Mathrandom() 9000) + 1000);// 随机函数
String path="";
if(sclx!=null&&sclxequals("1"))
path = "uploadsyj/" + nowTimesubstring(0, 6) + "/" + nowTimesubstring(0, 8) + "/";// 保存路径
else
path = "uploads/" + nowTimesubstring(0, 6) + "/" + nowTimesubstring(0, 8) + "/";// 保存路径
String savePath = ServletActionContextgetServletContext()getRealPath("");
savePath = savePathreplace("\\", "/");
if (!savePathsubstring(savePathlength())equals("/"))
savePath = savePath + "/";
savePath = savePath + path;
// 获取扩展名
if (uploadifyFileNamelastIndexOf("") >= 0) {
extName = uploadifyFileNamesubstring(uploadifyFileNamelastIndexOf(""));
}
newFileName = uploadifyFileNamesubstring(0, uploadifyFileNamelastIndexOf("")) + nowTimesubstring(8)
+ random + extName;
File file = new File(savePath);
if (!fileexists())
filemkdirs();
uploadifyrenameTo(new File(savePath + newFileName));
/
>package comletvdircloudutil;import comletvdircloudcontrollerDirectorWatermarkController;import orgslf4jLogger;import orgslf4jLoggerFactory;import javaio;import javanet>你做的是简单的上传?我这是spring的上传你可以用io流上传
public String picture(@RequestParam MultipartFile[] imgs,>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)