帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > ASP编程
不用组件实现上载功能(英文NT)2
作者:webwing 发布时间:2005-03-12 来源:chinaasp.com
'---- 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"> </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> <br>
<input class="btn" type="submit" value="Finish!" onClick="window.opener.focus();window.close();" id=submit1 name=submit1>
</form>
</body>
</html>

  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·不用组件实现上载功能(英文NT)  (2005-03-12)
 ·页面自动刷新,又不用让用户按回  (2005-03-12)
 ·不用正则表达式来实现非大小写替  (2005-03-12)
 ·不用图像组件的ASP图像计数器  (2005-03-12)
 ·ASP直接调用EXCEL数据的例子(不  (2005-03-12)
 ·不用编程,得到一个用户QQ在线状  (2005-03-12)
 ·不用询问关闭一个独立的窗口代码  (2005-03-12)
 ·不用 EOF 以加快记录循环  (2005-03-12)
 ·不用SQL语句查询DataTable中的数  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·在ASP中使用数据库
·使用ASP脚本技术
·通过启动脚本来感受ASP的力量
·学习使用ASP对象和组件
·解析asp的脚本语言
·初看ASP-针对初学者
·ASP开发10条经验总结
·ASP之对象总结
·ASP与数据库应用(给初学者)
·关于学习ASP和编程的28个观点
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统