www.gusucode.com > WapEditFile手机WAP文件管理器源码 > wap_upload.asp

    <%Response.Buffer=FALSE%>

<!--#include file="wap_verify.asp"-->
<%Server.ScriptTimeOut=5000%>

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-cache" />
<title>上传文件结果</title>
</head>
<body>

<!--#include FILE="wap_upload_5xsoft.asp"-->

<%
'判断字符串中是否有中文字符
'有-返回 true
'无-返回 false
'这里的中文字符可能还包括日文、韩文等东方文字
'在 ASP(VBScript 为语言)中,Asc 函数的返回值小于 0 的,可以被判断为中文字符。Asc 函数返回与字符串的第一个字母对应的 ANSI 字符代码。
function HasChinese(str)
    HasChinese = false   
    dim i
    for i=1 to Len(str)
        if Asc(Mid(str,i,1)) < 0 then
            HasChinese = true
            exit for
        end if
    next
end function
'if HasChinese(str)=true then response.redirect pathstr&"wap_err.asp?id=4" end if ''判断文件名称是否含有中文

on error resume next

response.write "<br><a href='wap_all.asp'>管理首页</a>-<a href='wap_logout.asp'>退出</a>"

set upload=new upload_5xsoft ''建立上传对象
set file=upload.file("file1") ''生成一个文件对象

formPath=trim(upload.form("filepath")) ''得到上传目录
if formPath="" then formPath="ceshi/" end if ''默认上传到ceshi文件夹
if right(formPath,1)<>"/" then formPath=formPath&"/" end if ''在目录后加(/)

if file.fileSize>0 then ''如果FileSize>0说明有文件数据
file.saveAs Server.mappath(formPath&file.FileName) ''保存文件
response.write "<br>上传文件:"&file.FilePath&file.FileName&" => "&formPath&file.FileName&" 成功!"
response.write "<br><br>注意:如果名称含有中文的文件,虽然上面提示说上传成功,但是其实没有上传成功或文件名称是乱码的文件等可能。"
end if
response.write "<br><a href='wap_upload_set.asp?FolderPath="&formPath&"'>再上传到相对路径:"&formPath&"</a>"
set file=nothing
set upload=nothing

response.write "<br><a href='wap_all.asp'>管理首页</a>-<a href='wap_logout.asp'>退出</a>"
%>

</body>
</html>