网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.不用组件实现上载功能(1).
.实现让每句话的头一个字母都大写.
.改进 ASP 应用程序中的字符串处理.
.在ASP中常见的错误80004005信息和.
.正则表达式的字符,定位字符和重.
.ASP环境下邮件列表功能的实现 (.
.将ASP的Debug变得简单的两个函数.
.在ASP中如何访问Novell下的数据库.
.用ASP实现自动建站.实现虚拟二级.
.怎样在网站上连接ORACLE数据库.
.创建弹出式“每日提示”窗口.
.建立自己的WEB平台.
.随机访问Recordset的一条记录.
.一种理论上最快的Web数据库分页方.
.Asp.Net控件加载错误的解决方法.
.服务器获得客户端时间的方法.
.通过地址栏传递参数.通过url传递.
.ASP中CACHE技术的应用.
.在ASP中取得服务器网卡的MAC地址.
.ASP访问SQL Server内置对象.

不用组件实现上载功能(2)

发表日期:2001-3-27


'---- file name /handld_upload.asp

<% Option Explicit %>

<%
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
Const IMAGE_SIZE = "width=""200"" height=""150"""
Dim UploadRequest
Set UploadRequest = Server.CreateObject("Scripting.Dictionary")

Dim byteCount, RequestBin
byteCount  = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)

BuildUploadRequest RequestBin

Dim saveURL, goURL, filepathname, value, filename
'---- save path
'saveURL      = UploadRequest.Item("saveURL").Item("Value")
saveURL      = "/"

'---- jump to file path when finish upload
goURL        = UploadRequest.Item("goURL").Item("Value")

filepathname = UploadRequest.Item("my_file").Item("FilePathName")
value        = UploadRequest.Item("my_file").Item("Value")
filename     = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))

'---- debug
'Response.Write saveURL&"**"&goURL&"**"&filepathname
'Response.Write "**"&filename
'Response.End

Dim fso, MyFile, i
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(Server.mappath(saveURL) & "\") Then
    RecMkDir(Server.mappath(saveURL) & "\")
End If
Set MyFile = fso.CreateTextFile(Server.mappath(saveURL) & "\" & filename)

For i = 1 to LenB(value)
    MyFile.Write chr(AscB(MidB(value,i,1)))
Next

MyFile.Close

Session("StoredFile") = filename
Session("strImage") = "<img src='" & saveURL &  filename & "'" & IMAGE_SIZE & " border=1 bordercolor=#0000FF>"

Response.Redirect goURL
%>
<!--#include file="upload.asp"-->

'---- file name /test.asp/
<% Option Explicit %>

<%
On Error Resume Next
Response.Expires = 0
Response.AddHeader "Pragma", "no-cache"

Dim thisFile
thisFile = Right(Request.ServerVariables("PATH_INFO"),Len(Request.ServerVariables("PATH_INFO"))-InStrRev(Request.ServerVariables("PATH_INFO"), "/"))

If Request("imageCancel") <> "" Then
    Session("StoredFile") = ""
    Session("strImage")   = ""
End If
%>
<html>
<head>
<title>Corp2Net.com</title>
<script language="JavaScript" src="/admin.js"></script>
<script language="JavaScript">
<!--
function UpLoad(obj)
{
    if (obj.my_file.value.length < 7)
            return false;
    return true;
}
// -->
</script>
<body link=<%= COLOR_NL_1 %> alink=<%= COLOR_AL_1 %> vlink=<%= COLOR_VL_1 %> bgcolor=<%= COLOR_BG_1 %>>
<font color="<%= C_WD_CONTENT_4 %>">
Only upload <b>*.jpg</b> or <b>*.gif</b> file!
<br>
Otherwise, image may not show correctly!
</font>
<center>
<table>
<% If ( Len(Session("strImage")) > 0 ) Then %>
<tr>
    <td>
        <table border="1" bordercolor="<%= C_WD_T_BORDER %>" cellspacing="0" cellpadding="0" <%= IMAGE_SIZE %>>
        <tr>
            <td><%= Session("strImage") %></td>
        </tr>
        </table>
    </td>
</tr>
<% Else %>
<tr>
    <td>
        <table border="1" bordercolor="<%= C_WD_T_BORDER %>" cellspacing="0" cellpadding="0">
        <tr>
            <td align="center" valign="top">
                <table cellspacing="0" cellpadding="0" border="0" <%= IMAGE_SIZE %>>
                <tr>
                    <td colspan="2"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>"><b>Upload / preview image:</b></font></td>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td valign="top" nowrap><font class="e-foot" color="<%= C_WD_CONTENT_4 %>"><b>Step 1:</b></font></td>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>">Prepare an image with 72 dpi resolution.</font></td>
                </tr>
                <tr>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>"><b>Step 2:</b></font></td>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>">Select your image file</font></td>
                </tr>
                <tr>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>"><b>Step 3:</b></font></td>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>">Press "Upload" button</font></td>
                </tr>
                <tr>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>"><b>Step 4:</b></font></td>
                    <td valign="top"><font class="e-foot" color="<%= C_WD_CONTENT_4 %>">Continue <b>OR</b> repeat <b>Step 1-3</b> to change the image</font></td>
                </tr>
                </table>
            </td>
        </tr>
        </table>
    </td>
</tr>
<% End If %>
</table>
</center>

<form method="POST" enctype="multipart/form-data" action="handle_upload.asp" onSubmit="return UpLoad(this)" id=form1 name=form1>
    <input type="hidden" name="saveURL" value="<%= WEB_TEMP_PATH %>">
    <input type="hidden" name="goURL" value="<%= Request.ServerVariables("PATH_INFO") %>">
    <input class="btn" type="file" name="my_file">
    <input class="btn" type="submit" name="submit" value="Upload" >
</form>

<form action="<%= thisFile %>" id=form2 name=form2>
<input class="btn" type="submit" name="imageCancel" value="Press Here To Cancel Image!">
<br>&nbsp;<br>
<input class="btn" type="submit" value="Finish!" onClick="window.opener.focus();window.close();" id=submit1 name=submit1>
</form>
</body>
</html>

上一篇:不用组件实现上载功能(1) 人气:13129
下一篇:在网页中实现OICQ里的头像选择的下拉框 人气:12974
浏览全部的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐