show.jsp
<%@ page contentType="text/html; charset=gb2312"%>
<%@ include file="/DataIni/DataOpen.jsp"%>
<%@ include file="/ScriptLib/Init.jsp"%>
<%
String Id,TypeValue;
Id=request.getParameter("Id");
TypeValue=request.getParameter("Type");
odbcQuery="select * from MediaLib where ID="+Id;
odbcRs=odbcStmt.executeQuery(odbcQuery); byte[] Buffer=new byte[1024*10];
InputStream InData=null;
OutputStream outData=null;
int iSize;
if(odbcRs.next())
{
outData=response.getOutputStream();
InData=odbcRs.getBinaryStream("MediaFile");
response.setContentType(TypeValue);
while(true)
{
iSize=InData.read(Buffer);
if(iSize==-1)
{
break;
}
outData.write(Buffer,0,iSize);
}
outData.flush();
response.flushBuffer();
}
odbcRs.close();
%>
<%@ include file="/DataIni/DataClose.jsp"%>显示:
function ShowMedia(Id,Type)
{
var hwnd=window.open('','','');
switch(Type)
{
case "image/*":
hwnd.document.write("<Img src='/System/Media/Show.jsp?Id="+Id+"&Type="+Type+"' border=0></a>");
break;
case "audio/*":
hwnd.document.write("<BgSound src='/System/Media/Show.jsp?Id="+Id+"&Type="+Type+"' border=0>");
break;
case "video/*":
hwnd.document.write("<Img dynsrc='/System/Media/Show.jsp?Id="+Id+"&Type="+Type+"' border=0></a>");
break;
case "application/msword":
hwnd.location.href="/System/Media/Show.jsp?Id="+Id+"&Type="+Type;
break;
case "application/vnd.ms-excel":
hwnd.location.href="/System/Media/Show.jsp?Id="+Id+"&Type="+Type;
break;
case "application/*":
hwnd.location.href="/System/Media/Show.jsp?Id="+Id+"&Type="+Type;
break;
default:
break;
}
}