[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[整理]测试ASP使用SA FileUp组件上传的一小段代码。

上一篇:[读书笔记]C#进行windows程序设计[01]
下一篇:[整理]SQL Server的T-SQL的一点学习笔记

添加日期:2008/3/4 14:48:13 快速返回   返回列表 阅读4246次
两个文件放在一起,文件保存到upfile目录下。

upfile.asp


<% @codepage=936 EnableSessionState=False%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传测试页</title>
</head>

<body>
<script>
function checkForm(){
    if(fileForm.file1.value==""){
        alert("请选择文件。");
        return false;
    }
    return true;
}
</script>
<form name="fileForm" method="post" action="saveFile.asp" enctype="multipart/form-data" onSubmit="return checkForm();">

File:<INPUT name="file1" type="file" size="20"> 请小于2M<br>
<input name="Submit" type="submit" class="myButton" value="开始上传">
</form>
</body>
</html>



saveFile.asp


<% @codepage=936 EnableSessionState=False%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传结果</title>
</head>

<body>
<%
Server.ScriptTimeOut=300
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
formPath="upfile/"    '文件保存位置

if oFileUp.Form("file1").TotalBytes>1024 *1024 *2 then
    errMsg=errMsg+"文件:"&oFileUp.Form(strFormElement).UserFileName&" 大于2M!<br>"
else
    strShortFileName = mid(oFileUp.Form("file1").UserFileName,InStrRev(oFileUp.Form("file1").UserFileName, "\")+1)  '取得文件名
    oFileUp.Form("file1").SaveInVirtual formPath & strShortFileName  '保存文件
    errMsg="save ok. <input type='button' value='..back..' onClick='history.go(-1);'"
end if
response.write errMsg
%>
</body>
</html>

 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved