📄 photor1.asp
字号:
SizeString=Round(Size/1024/1024) & "MB"
ElseIf Size>1024*1024 Then
SizeString=Round(Size/1024/1024,1) & "MB"
ElseIf Size<1024 Then
SizeString="1kB"
ElseIf Size>100*1024 AND Size<1024*1024 Then
SizeString="0" & Round(Size/1024/1024,1) & "MB"
Else
SizeString=Round(Size/1024) & "kB"
End If
End Function
'========================
SUB ShowError(Info)
'========================
Response.Clear
Response.write "<dir><font face=arial size=2 color=222222><font color=EE0000><h3>对不起,发生错误!</h3></font>"
If Info<>"" Then Response.write "<b></b> " & Info & "<br><br>"
Response.write "<b>导致错误的原因可能是</b>"
Response.write "<li>没有权限"
Response.write "<li>不合法的文件或路径"
Response.write "<li>文件或路径没有找到"
Response.write "<li>文件或目录已经存在"
If RootFolder="" then t=Server.Mappath("/") else t= RootFolder
Response.write "<br><br><a href=photo.asp?dir="& dir & ">图片列表</a>"
Response.write "<br><br><form><input type='button' value=' 返回 ' onclick='history.go(-1)';></form>"
Response.end
End Sub
'========================
SUB Del(f)
'========================
On error resume Next
tArr=Split(f,", ")
For i=0 to Ubound(tArr)
On error resume Next
If Instrrev(tArr(i),"\")=Len(tArr(i)) Then ' Dir
tArr(i)=Left(tArr(i),Len(tArr(i))-1) ' Remove trailing "\"
fso.deleteFolder tArr(i), True
Else
fso.deleteFile tArr(i), True
End If
path=Left(tArr(i),Instrrev(tArr(i),"\")-1)
Next
If err<>0 Then Call ShowError("删除文件: " & f) Else Response.redirect "photo.asp?dir=" & path
End Sub
'========================
Function StartCapital(s)
'========================
If BeautifyFileNames Then StartCapital=UCase(left(s,1)) & LCase(Mid(s,2)) Else StartCapital=s
End function
'========================
Function FormatDate2String(snow)
'========================
If Not IsDate(snow) Then snow=Now()
yyyy=Year(snow)
mm=Right("0" & Month(snow),2)
dd=Right("0" & Day(snow),2)
m =Right("0" & Minute(snow),2)
s =Right("0" & Second(snow),2)
FormatDate2String=yyyy & mm & dd & m & s
End Function
'========================
SUB Upload(Dir)
'========================
On error resume Next
ULItems=3
Server.ScriptTimeOut =600
strFileName=Request("acode")
Set objTool = new upload_5xSoft '采用无组件上传图片
If err<>0 Then ShowError("上传组件无法加载,请确定服务器是否支持该功能!")
If Len(strFileName)<2 Then
%>
<script language="javascript">
function checkimg(){
var fileext;
var my_value;
if(document.all.file1.value!=""){
my_value=document.all.file1.value;
fileext=my_value.substr(my_value.length-3,3);
fileext=fileext.toUpperCase();
if ((fileext != "GIF") && (fileext != "JPG")){
alert("请在图片域中输入gif或jpg图片文件名称!");
document.all.file1.focus();
return false;
}
}
//
if(document.all.file2.value!=""){
my_value=document.all.file2.value;
fileext=my_value.substr(my_value.length-3,3);
fileext=fileext.toUpperCase();
if ((fileext != "GIF") && (fileext != "JPG")){
alert("请在图片域中输入gif或jpg图片文件名称!");
document.all.file2.focus();
return false;
}
}
//
if(document.all.file3.value!=""){
my_value=document.all.file3.value;
fileext=my_value.substr(my_value.length-3,3);
fileext=fileext.toUpperCase();
if ((fileext != "GIF") && (fileext != "JPG")){
alert("请在图片域中输入gif或jpg图片文件名称!");
document.all.file3.focus();
return false;
}
}
}
</script>
<form enctype="multipart/form-data" name="frmfile" method="post" onsubmit="javascript:return checkimg();" action="photo.asp?a=upload&acode=$$$$$$">
<font face=arial size=2 color=000080><b>上传图片</b></font><br><br>
<font face=arial size=1>图片大小不能超过(支持jpg、gif格式): </font><font face=arial size=1 color=red><%=SizeString(MaxTransferSize)%></font><br>
<%For i=1 to ULItems
Response.write "<input type=file name=file"& i & " size=40><br>"
Next%>
<br>
<INPUT type="submit" name=a value="上传" style="width:80px;height:22px;">
<INPUT type="button" name=b value="取消" style="width:80px;height:22px;" onclick="javascript:history.back();">
</form>
<%
Else
If Request.TotalBytes<=MaxTransferSize Then
For i=1 to ULItems
set file=objTool.file("file"&i)
if file.filesize>0 then
filename="pic" & FormatDate2String(Now()) & i & right(file.FileName,4)
file.SaveAs Dir & "\" & filename
end if
set file=nothing
Next
Else
ShowError("图片大小超过限制!<br> 图片大小限制为: <font color=red>" & SizeString(MaxTransferSize) & "</font>")
End If
If err<>0 Then Call ShowError("Uploading selected files to " & dir & VbCrLf ) Else Response.redirect "photo.asp?dir=" & dir
End If
Set objTool =Nothing
End Sub
'========================
SUB ShowToolbar(Dir)
'========================
On error resume Next
%>
<SCRIPT>
if (document.layers){
document.captureEvents(Event.KEYPRESS);
document.onkeypress =function (evt) {
var key = document.all ? event.keyCode : evt.which ? evt.which : evt.keyCode;
if (key ==13)
document.listform.submit();
}
}
function findit(){
var folder=prompt("查找文件(支持模糊查找)","");
if ((folder!="") && (folder!=null))
{
document.listform.action="photo.asp?a=find&f="+folder;
document.listform.submit();
}
}
function submitform(action){
var target=prompt("Enter target folder:","<%=Replace(dir,"\","\\")%>");
if ((target!="") && (target!=null)) {
document.listform.action="photo.asp?a="+action+"&target="+target;
document.listform.submit();
}
}
function del(){
if(confirm("删除选中的文件吗?\n注意:文件删除不能恢复!")){
document.listform.action="photo.asp?a=del";
document.listform.submit();
}
}
function CheckAll(){
for (var i=0;i<document.listform.elements.length;i++) {
var e = document.listform.elements[i];
if (e.name != 'allbox'){
e.checked = document.listform.allbox.checked;
}
}
}
function showimg(picname){
window.open("showimg.asp?pic_name="+picname,"photo","toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,width=20,height=20,top=100,left=180'");
}
</SCRIPT>
<script language="vbscript">
sub sendmsg(imgname)
dim img_name
img_name=imgname
img_path="<%=Replace(Request.ServerVariables("SCRIPT_NAME"),"/htmleditor/photo.asp","/uploadImages/")%>"
imglink="<IMG src="""+img_path+img_name+""" border=""0""><br><br>"
if not window.opener.closed then
dim tmpstr
tmpstr=window.opener.parent.Composition.document.body.innerHTML
tmpstr=imglink & tmpstr
window.opener.parent.Composition.document.body.innerHTML=tmpstr
window.close(true)
else
if msgbox("HTML编辑器已经关闭!",vbQuestion+vbYesNo,"提问")<>vbYes then
window.close(true)
else
window.open "photo.asp"
end if
end if
end sub
</script>
<script src="ImgResize.js"></script>
<style type="text/css">
a:link {color: #000080 }
a:active {color: #0000FF }
a:visited {color: #000080 }
a:hover { color: #BB0000 }
</style>
<body onload="javascript:MM_Imgs();" STYLE="MARGIN: 0pt; PADDING-BOTTOM: 0pt; PADDING-LEFT: 0pt; PADDING-RIGHT: 0pt; PADDING-TOP: 0pt">
<%
Response.write "<FORM Name=listform Method=post action=photo.asp>"
Response.write "<table width=445 cellpadding=1><tr bgcolor=menu><td><font face=arial size=2 color=333333> "
Response.write " <font color=red size=2></font><input name=Dir type=hidden style='font-family: arial; font-size: 11' value='" & Dir & "' size=25>"
Response.Write " </td><td> <font color=red size=2>"
Response.Write "<a href='javascript:location.reload()'><img src=images/refresh.gif border=0 Alt='刷新'></a> "
Response.Write "<a href=photo.asp?a=upload><img src=images/upload.gif border=0 Alt='上传图片'></a> "
Response.Write "<a href='javascript:findit()'><img src=images/find.gif border=0 Alt='查找文件'></a> "
Response.Write "<a href='javascript:del();'><img src=images/del.gif border=0 Alt='删除选中文件'></a> "
Response.Write "</font></td></tr></table>"
End sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -