网站建设已成为企业、个人展示形象、拓展业务的重要途径。ASP(Active Server Pages)作为微软公司推出的一种服务器端脚本环境,凭借其强大的功能、易用性,在众多服务器端脚本语言中脱颖而出。本文将基于ASP源码图片一,深入剖析ASP技术的秘密与魅力。
一、ASP源码图片一解析
1. 图片一简介
ASP源码图片一展示了一个典型的ASP页面结构,包括HTML、ASP代码和服务器端组件。通过分析该图片,我们可以了解ASP页面的基本构成和运行原理。
2. 图片一解析
(1)HTML部分
图片一中的HTML部分主要包括标题、导航栏、内容区域和页脚。这些元素构成了一个完整的网页结构,为用户提供浏览和交互的基础。
(2)ASP代码部分
图片一中的ASP代码部分展示了ASP页面的核心功能。以下是对部分代码的解析:
① Response.Write(\
ASP无组件上传图片源代码
<%
'上传方法,0=无组件,1=chinaaspupload
dim upload_type
upload_type=upload
dim uploadsuc
dim Forumupload
dim ranNum
dim uploadfiletype
dim upload,file,formName,formPath,iCount,filename,fileExt
response.write "<body leftmargin=0 topmargin=0>"
select case upload_type
case 0
call upload_0()
case 1
call upload_1()
case else
response.write "本系统未开放插件功能"
response.end
end select
sub upload_0()
set upload=new upload_5xSoft ''建立上传对象
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
response.write "<body leftmargin=5 topmargin=3>"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<100 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if
if file.filesize>1024000 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if
fileExt=lcase(getFileExtName(file.fileName))
if fileext<>"jpg" and fileext<>"png" and fileext<>"gif" and fileext<>"bmp" then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">该文件格式不允许上传 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if
randomize
rannum=int(90000*rnd)+10000
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&rannum&"."&fileExt
%>
<%
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath &filename) ''保存文件
response.write "<script>parent.document.FrmAddLink.photo.value='uploadfile/face/"&FileName&"'</script>"
end if
set file=nothing
next
set upload=nothing
Htmend iCount&" 个文件上传结束!"
end sub
sub HtmEnd(Msg)
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片上传成功 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end sub
sub upload_1()
set FileUp=server.createobject("ChinaASP.UpLoad") ''建立上传对象
filepath=server.MapPath("../uploadfile/face/")
response.write "<body leftmargin=5 topmargin=3>"
for each f in fileup.Files ''列出所有上传了的文件
if f.filesize<100 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if
if f.filesize>1024000 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if
fileExt=lcase(getFileExtName(f.fileName))
if fileext<>"jpg" and fileext<>"png" and fileext<>"gif" and fileext<>"bmp" then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">该文件格式不允许上传 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if
randomize
rannum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&rannum&"."&fileExt
%>
<%
if f.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
f.saveas filePath & "\"&filename ''保存文件
response.write "<script>parent.document.FrmAddLink.photo.value='uploadfile/face/"&FileName&"'</script>"
end if
set f=nothing
next
set FileUp=nothing
Htmend iCount&" 个文件上传结束!"
end sub
sub HtmEnd(Msg)
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片上传成功 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end sub
%>
想只指定文件夹路径,而不选择文件就实现文件的批量上传,不用控件是无法实现的。
服务器端不可能去扫描到你客户端的硬盘中的数据,除非你在浏览网页时安装activex控件,由这个控件来扫描你的硬盘中指定文件夹路径下的文件
你现在想实现的,就是批是把一个文件夹中的图片全部上传到服务器,那么又要无组件上传,就肯定不能用activex控件了。
我提供的解决办法就是:使用flash进行文件上传,像swfupload这种flash文件上传组件,只显示文件浏览一个按钮,你可以在代码中设置是只允许选择一个文件进行上传,还是选择多个文件进行批量上传。上传是无刷新的效果,还可以实时显示上传进度。
如果你觉得这种方案可以满足你的要求(实际上就只是比你的需求多了一个选择文件的步骤),swfupload的具体代码,可以QQ我17595923,我可以把我项目中用到的代码以及swfupload中文手发给你。
----
另外补充一下:楼上几位说的批量上传组件,早就有了,只不过与楼主的需求不太适合。但用flash来实现,那就是天衣无缝了,而且也已经有现成的flash上传组件,swfupload这么好的工具,我的项目中也早就用上了。其实楼主的需求,最麻烦的是客户端的文件选择,而不是服务器端的上传代码。
所以,使用swfupload这个上传组件最方便实用,只是几个js文件,几个flash文件,就实现了客户端的文件批量选择,并且还是无刷新数据上传,实时显示文件上传进度。
服务端的ASP代码,随便用一个无组件上传都OK,像无惧文件上传类、风声无组件上传类等都是很好的ASP无组件上传类。
建议使用fck2.6.3以上版本.
首先,打开fckeditor下的fckconfig.js文件,找到FCKConfig.ToolbarSets["Default"]和FCKConfig.ContextMenu 在他们后面加上”InsertCode”,这个当然是自己要添加的工具栏的名字了。然后,我们在“fckeditor\editor\lang\”文件夹下找到zh-cn.js,在最后一行后面加上以下2句:
//自定义
InsertCode:"插入代码",
InsertCodeProp:"插入代码属性"
注意在这2句前DlgAboutInfo : "要获得更多信息请访问 "后面加个逗号。当然,还可以同样方法修改其他语言js文件,我就修改了繁体的zh.js和英文的en.js
现在,我们已经定义了工具栏,开始第二大步,打开“fckeditor\editor\js\”下的fckeditorcode_gecko.js和fckeditorcode_ie.js,我们开始注册工具栏;
第一步:在2个文件中搜索“InsertHorizontalRule”,在后面加上“InsertCode”。
第二步:同样在2个文件中搜索“default:if (FCKRegexLib”,在“default”之前加上这么一句:
Case 'InsertCode':B = new FCKDialogCommand('InsertCode' , FCKLang.InsertCode ,'dialog/InsertCode/InsertCode.htm',510,450);break;
这句话意思就是,点击工具栏图标时打开InsertCode.htm文件,定义了高和宽,至于文件内容我们之后再说。
第三步:还是在这2个文件,搜索“default:alert(FCKLang.UnknownToolbarItem”,在“default”之前加上下面一句:
case 'InsertCode':B = new FCKToolbarButton('InsertCode' , FCKLang.InsertCode,null,null,null,null,67);
这句话意思是定义了工具栏的图标,FCKeditor的默认图标文件是“fckeditor\editor\skins\default\”下的fck_strip.gif图片,本人由于不想用重复的默认图标,因此加了一个小图片:
(20*20)
默认图片是16*2056,用PS把画布加长到16*2072,再把自己的小图片放到最下面,这样,自定义的图片刚好排67位。以后加新功能还可以依次增加此图片。
好了。经过这么3步,我们已经把自定义工具栏加上去了。(在about之后,如果想加在中间,可以在刚才的第二和第三步里把添加的语句加到相应的Case前面。)
做了这么多,任务算完成1/3,加油!
下面我们开始定义“InsertCode.htm”文件:
在“fckeditor\editor\dialog\”下新增InsertCode文件夹,新建HTM文件InsertCode.htm,里面代码先拷贝“fckeditor\editor\dialog\fck_textfield.html”文件,好了,,大手术开始:
首先,在“<title></title>”中加上“Insert Code Properties”,这个是打开的新窗体的标题;更改FCKeditor的JS文件“common/fck_dialog_common.js”的引用为“../common/fck_dialog_common.js”,再加上双鱼编辑器里的插入代码脚本“<script src="code.js" type="text/javascript"></script>”。
然后更改“window.onload = function()”函数,把里面的if {} else{}删除掉,再把function Ok()里的代码全部删除,加上下面2句:
oEditor.FCK.InsertHtml(code()) ;
window.parent.Cancel() ;
因为我们是更改成代码格式的字符串加到FCKeditor编辑器里,所以用到内置的InsertHtml函数,code()函数传过来的是字符串;至于下面的html代码,就更改为双鱼编辑器里InsertCode.htm的代码(这里就不提供了,本人把更改好的放上来,这里只做个简单说明)。
下面我们修改“code.js”文件里的代码,把“function code()”里的
window.returnValue = FormateCode(str,language,showLine,canCollapse,c****lCollapse,allRegion);
window.close();
这两句更改为一句:
return FormateCode(str,language,showLine,canCollapse,c****lCollapse,allRegion);
好了,至此,就可以使用插入代码功能了。(添加其他功能的时候到这一步就可以完成了。)
文章已关闭评论!
2025-05-09 23:05:13
2025-05-09 22:45:22
2025-05-09 22:33:25
2025-05-09 22:22:51
2025-05-09 22:01:11
2025-05-09 21:15:02
2025-05-09 21:02:22
2025-05-09 20:43:13