제목과 마찬가지로 파일명이 한글인 이미지를 서버에 업로드 시킬려고 하는데 한글 파일명이 깨지는게 아니라, 아예 업로드 자체가 안됩니다. 혹시 해결 방법을 도와주실 수 있을까 하여 글을 올려 봅니다.
안드로이드 업로드 소스 부분은
public void doFileUpload(){
try{
HttpClient httpClient = new DefaultHttpClient();
String url = "http://180.227.155.25:8080/Server43.jsp?type=1";
HttpPost post = new HttpPost(url);
File saveFile = new File(Environment.getExternalStorageDirectory()+"/DCIM/Camera1/"+"한글로 된 파일명");
FileBody bin = new FileBody(saveFile);
MultipartEntity multipart = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
multipart.addPart("images", bin);
post.setEntity(multipart);
HttpResponse response = httpClient.execute(post);
HttpEntity resEntity = response.getEntity();
} catch (Exception e){
e.printStackTrace();
}
}
이고요,
서버쪽 받는 jsp 부분은
<%@ page import="java.io.*, com.oreilly.servlet.*, com.oreilly.servlet.multipart.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head><title>upload test</title></head>
<body>
<%
String type = request.getParameter("type");
String dir = "";
if(type.equals("1")){
dir = application.getRealPath("/upload");
} else if(type.equals("2")){
dir = application.getRealPath("/facephoto");
}
int max = 5*1024*1024;
MultipartRequest m = new MultipartRequest(request, dir, max, "UTF-8");
%>
</body>
</html>
입니다.
영문 파일명은 업로드가 되고 있습니다. 그럼 도움 부탁드립니다. 수고하세요!