前台准备
- 表单必须是post提交
- 提交类型为enctype,多段式提交
- 使用<input type="file" />组件
<form id="form" name="form" action="..." method="post" enctype="multipart/form-data">
后台接受
private File photo;
private String photoFileName;
get
set
photo.renameTo(new File("C:/ypload/test.jpg"));
public void setPhoto(File photo){
this.photo=photo;
}
public File getPhoto(){
return photo;
}
网友评论