Skip to content

Commit

Permalink
修改个活动图片上传的小bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Evans-xie committed Apr 8, 2018
1 parent d2c9bd1 commit 2227317
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public Msg pushActivity(HttpServletRequest request, @PathVariable("userId") int
}
try {
String accessPath=picService.save2Local(pic, pic.getOriginalFilename());
return Msg.success("头像更新成功").add("iconAccessPath", accessPath);
return Msg.success("图片上传成功").add("picAccessPath", accessPath);
}catch (QingxieInnerException e){
return Msg.error(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FileUtil {
* @return
*/
public static String getAccessPath(int userId, String fileName) {
return ICON_PATH + "icon" + getSubPath(userId, fileName);
return ICON_PATH + "icon" + "/" + getSubPath(userId, fileName);
}

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ public static void save(InputStream in, String name) throws IOException, Qingxie
public static String savePic(InputStream in, String name) throws IOException, QingxieInnerException {
mkdir(PIC_SAVE_PATH);
String newName = getRandomName(name);
try (FileOutputStream fos = new FileOutputStream(newName)) {
try (FileOutputStream fos = new FileOutputStream(PIC_SAVE_PATH+"/"+newName)) {
byte[] bytes = new byte[in.available()];
in.read(bytes);
fos.write(bytes);
Expand Down
6 changes: 6 additions & 0 deletions QingXie/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@

<h4>活动报名<input type="button" value="/{activityId}/{userId}/join" id="joinActivity"/></h4>

<h4>活动照片上传
<form action="/activity/3/pic/add" enctype="multipart/form-data" method="post">
请选择图片:<input type="file" name="pic" id="pic" value="【图片】">
<input type="submit" value="上传" id="uploadPic">
</form>
</h4>

<h4>登陆接口测试</h4>
<form action="/user/login" method="post">
Expand Down

0 comments on commit 2227317

Please sign in to comment.