0
Play Framework 2.0.4를 사용 중입니다. 다음은 시도한 코드입니다.로컬 시스템의 지정된 위치에 이미지 저장
public static Result save() throws FileNotFoundException {
Form<Tenant> tenantForm = form(Tenant.class).bindFromRequest();
Form<Ten> tenForm = form(Ten.class).bindFromRequest();
Long tenantid = tenForm.get().tenant_id;
Http.MultipartFormData body = request().body().asMultipartFormData();
Http.MultipartFormData.FilePart picture = body.getFile("logo_url");
if (picture != null) {
String fileName = picture.getFilename();
String contentType = picture.getContentType();
File file = picture.getFile();
tenantForm.get().logo_url = file.getPath();
tenantForm.get().save();
return redirect(
routes.Application.index()
);
} else {
flash("error", "Missing file");
return redirect(
routes.Project.ctstenant(0,"name","asc","","",tenantid)
);
}
}
임시 폴더에 이미지가 저장됩니다. 지정된 폴더에 저장하고 싶습니다. 예제와 함께 감사하겠습니다.
도움 주셔서 감사합니다.
왜 파일을 임시에서 원하는 위치로 이동하지 않으시겠습니까? – Carsten