求一段 SSH上传图片的代码,只需要把路径存到数据库中即可
1个回答
展开全部
UploadActionForm uaf = (UploadActionForm)form; ///UploadActionForm 是封装了formbean的java类
System.out.println("title:"+uaf.getTitle());
FormFile myFile = uaf.getMyfile();
if(null != myFile) {
System.out.println("fileName:"+myFile.getFileName());
FileOutputStream fos = new FileOutputStream ("d:\\+你要上传到服务器的路径);
fos.write(myFile.getFileData());
fos.flush();
fos.close();
}
System.out.println("title:"+uaf.getTitle());
FormFile myFile = uaf.getMyfile();
if(null != myFile) {
System.out.println("fileName:"+myFile.getFileName());
FileOutputStream fos = new FileOutputStream ("d:\\+你要上传到服务器的路径);
fos.write(myFile.getFileData());
fos.flush();
fos.close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询