日期:2010-02-16  浏览次数:20882 次

简单的ASP无组件上传类,发出来让大家看看。可以做做实验!

以下为引用的内容:

<%@ language="javascript"%>
<%
var self = Request.serverVariables("SCRIPT_NAME");
if (Request.serverVariables("REQUEST_METHOD")=="POST")
{
        var oo = new uploadFile();
        oo.path = "myFile";                        //存放路径,为空表示当前路径,默认为uploadFile
        oo.named = "file";                        //命名方式,date表示用日期来命名,file表示用文件名本身,默认为file
        oo.ext = "all";                                //允许上传的扩展名,all表示都允许,默认为all
        oo.over = true;                                //当存在相同文件名时是否覆盖,默认为false
        oo.size = 1*1024*1024;                //最大字节数限制,默认为1G
        oo.upload();
        Response.write('<script type="text/javascript">location.replace("'+self+'")</script>');
}

//ASP无组件上传类
function uploadFile()
{
    var bLen  = Request.totalBytes;
    var bText = Request.binaryRead(bLen);
    var oo = Server.createObject("ADODB.Stream");
    oo.mode = 3;
        this.path = "uploadFile";
        this.named = "file";
        this.ext = "all";
        this.over = false;
        this.size = 1*1024*1024*1024;        //1GB

        //文件上传       
        this.upload = function ()
        {
                var o = this.getInfo();
                if (o.size>this.size)
                {
                        alert("文件过大,不能上传!");
                        return;               
                }
     &nb