일단 소스 붙여 넣겠습니다.
<%@ page language="java" contentType="application" %>
<%@ page import="java.io.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.*" %>
<%!
private void transport(InputStream in, OutputStream out) throws IOException{
BufferedInputStream bin = null;
BufferedOutputStream bos = null;
try{
bin = new BufferedInputStream(in);
bos = new BufferedOutputStream(out);
byte[] buf = new byte[2048]; //buffer size 2K.
int read = 0;
while ((read = bin.read(buf)) != -1) {
bos.write(buf, 0, read);
}
}finally{
bos.close();
bin.close();
}
}
%>
<%
request.setCharacterEncoding("EUC-KR");
String filename = "www/qrcode.png";
InputStream in = null;
OutputStream os = null;
try{
File file = new File(filename);
in = new FileInputStream(file);
String savefname = new String(filename.getBytes(),"ISO8859_1");
response.reset() ;
response.setContentType("application/smnet");
response.setHeader("Content-Disposition", "attachment; filename=\"" + savefname +"\"");
response.setHeader("Content-Length", ""+file.length());
transport(new FileInputStream(file), response.getOutputStream());
}catch(IOException e){
e.printStackTrace();
}finally{
if(in !=null)try{in.close();}catch(Exception e){}
if(os !=null)try{os.close();}catch(Exception e){}
}
%>
위의 jsp소스를 이용해서 이미지 파일 클릭시 다운로드를 구현하였는데
explorer에서는 정상작동이 되는것을 확인하였는데
안드로이드로 접속시에 클릭하면 아무 반응이 일어나지 않습니다.
이미지 클릭시 다운받는 소스는
function downloadFile(filename){
document.fileForm.FILENAME.value = filename;
document.fileForm.target = "ifrm";
document.fileForm.submit();
}
<a href="javascript:downloadFile('qrcode.png')"> <img src="qrcode.png"></a>
이런식으로 되어있습니다.
고수님들 가르침 부탁드립니다.