- 热门文章:
- · 精华asp代码
- · ASP中的函数说明
- · FileCopy
- · 事务处理
- · ASP中得到用户的真实IP地址
- · ASP编程中15个非常有用的例子
- · InStrRev 函数
- · 新写的一个定时新闻小偷
- · 一段自动补位的函数(ASP)
- · VBS 中 Space 函数的应用
- · 游走于ASP与ASP.NET的郁闷
- · 用ASP的安全验证来对windows 2000的管理者密码进行在线修改
上一篇:利用ASP得到图片尺寸大小 >>
如何处理ASP中的图象
file&: showimg.asp
***************************************
<%@ language="vb" %>
<%
clear out the existing http header information
response.expires = 0
response.buffer = true
response.clear
change the http header to reflect that an image is being passed.
response.contenttype = "image/gif"
set cn = server.createobject("adodb.connection")
the following open line assumes you have set up a system datasource
by the name of mydsn.
cn.open "dsn=mydsn;uid=sa;pwd=;database=pubs"
set rs = cn.execute("select logo from pub_info where pub_id=0736")
response.binarywrite rs("logo")
response.end
%>
*****************************************
执行这个asp文件就可以看到你存在数据库中的图象了。
但如果是同时处理文字和图象就会有些困难了:-(
比如:一个企业的人员管理,后台数据库可以用sybase或sql server等。(我在这用sql server)当你在企业内部需要用到browse/server方式,即用浏览器查看员工的个人信息时,就即要处理文字信息同时还要用到关于图象的技巧。
问题在于你显示文字信息时html的head中的content=“text/html”,而显示图象则必须是content=“image/gif”或者是content=”image/jpeg“。因此你是无法只用一个asp文件就把文字信息和图象都处理完的,解决的办法是:用一个单独的asp文件处理图象,然后在处理文字信息的asp文件中调用这个asp文件。
在这给大家介绍一个我的解决方法,希望大家一起讨论:
环境:winnt4.0 sql server iis3.0
数据库名:rsda
表名:rsda_table
目的:从rsda_table中查出id=00001的人员的信息,包括姓名,年龄和照片
第一步:创建一个查询表单rsda.htm:
**********************************
<html>
<head>
</head>
<body>
<form method ost" action="search.asp">
<p>请输入编号:<input type="text" name="t1" size="20"><input
type="submit" value="提交" name="b1"><input type="reset" value="复原" name="b2"></p>
</form>
</body>
</html>
***********************************
第二步:建立search.asp
***********************************
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<title>查询结果</title>
</head>
<body bgcolor=azure>
<%
session("rsda_id")=request.form("t1") 这里我用了一个session变量,是为了在处理图象的asp文件中再次调用
temp_id=session("rsda_id")
<font size=4 color=orangered> 查询结果:</font>
<%set conntemp=server.createobject("adodb.connection")
conntemp.open "dsn=rsda;uid=sa;pwd=sa"
set rstemp=conntemp.execute("select * from rsda_table where rsda="&temp_id&"")
%>
<% put headings on the table of field names
nobody="对不起!在我们的数据库里没有您要找的资料!"%> 判断是否有这个人
<%if rstemp.eof then %>
<font size="5" color=orangered> <%response.write(nobody)%></font>
<%else%>
<div align="center">
<center>
<table border="1" width="73%" height="399">
<tr>
<td width="21%" height="49" align="center"><p align="center">姓 名</td>
<td width="30%" height="49" align="center">
<font size=4 color=orangered><%=rstemp(0)%></font></td>
</td>
<tr>
<td width="21%" height="47"><p align="center">年 龄</td>
<td width="30%" height="47" align="center">
<font size=4 color=orangered><%=rstemp(0)%></font></td>
</tr>
<tr>
<td width="49%" height="146" rowspan="3" colspan="2">
<img src="jpg.asp"></td> jpg.asp就是我们将要建立的专门处理图象的asp文件
</tr>
</table>
</center></div>
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
</body>
</html>
***********************************
第三步:建立处理图象的asp文件(jpg.asp) 。
***********************************
<%
response.expires = 0
response.buffer = true
response.clear
open database
set conntemp = server.createobject("adodb.connection")
conntemp.open "dsn=rsda;uid=sa;pwd=sa"
change http header
response.contenttype = "image/jpeg" or "image/gif"
get picture
temp_id=session("rsda_id")
set rs = conntemp.execute("select photo from rsda_table where id="&temp_id&"")
response.binarywrite rs("photo")
session.abandon
response.end
%>
**********************************
这里主要就是用到了一个小技巧就是利用了一个session变量来实现两次同条件查询。大家如我上述只需少量改动,就可以实现一个页面既有文字又有图象了!
下一篇:精华asp代码 >>
相关文章:
- · ADSI,使用ASP来完成NT管理
- · 被ASP的小问题难倒!
- · 域名查询系统--适合新手
- · asp模块化分页
- · ASP分页显示详论
- · Iframe高度自适应
- · 正则表达式大全
- · WMI学习
- · Session 详解
- · 关于交叉报表的动态实现
- · 页面执行需要长时间时向用户的提示信息
- · 使用Repeater模板 二
- · Sucess On a Horse
- · 校友通讯资料管理系统(1)
- · ASP实现图片上存
- · 提高网站在搜索引擎中的排名
- · 关于无组上传的老话题
- · 如何实现图片的随机生成与显示
- · 怎么把webapplication打包成安装文件
- · 为treeview添加客户端事件
- · 如何让不同的语言版本显示正确的中文?
- · 线程的处理(2)
- · 线程的处理(1)
- · 再谈ASP防止SQL Injection漏洞的问题
- · 用asp编写文档搜索页面
- · ASP中使用SQL语句
- · 利用反射动态调用类成员
- · Asp.net组件设计浅论
- · 越过调试这道槛——ASP.NET无法调试问题剖析
- · 一段用ASP查看ASP文件源码的程序.
- · ASP显示在线人数
- · Asp.net多页面间保留状态
- · 简单ASP计数器
- · 使用 HttpContext.RewritePath 来配合 Server.Transfer/Execute
- · SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
- · SQL Server 存储过程的分页
- · 经典的asp整理
- · Access中分组统计的实例
