📄 upload2.asp
字号:
<!--#include file="admin_include.asp"-->
<%
if request.QueryString("FileName")<>"" then
op = request.QueryString("op")
if op <> 0 then
conn.execute("update [Soft] set SD_Soft_Img='' where SD_Soft_id="&op)
session("ImgFile")=""
end if
FileName=request.QueryString("FileName")
set myobj=server.CreateObject("Scripting.FileSystemObject")
if not myobj.FileExists(server.MapPath("../images/upload/"&FileName&"")) then
session("UploadFile")=""
else
myobj.deleteFile server.MapPath("../images/upload/"&FileName&"")
session("UploadFile")=""
end if
set myobj=nothing
'response.Redirect("UploadFile2.asp")
response.Write("删除成功!")
response.End()
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--#include file="../js/inc.js"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/main.Css" />
<title>图片上传</title>
<style>
<!--
body {
background:#f5f5f5;
margin:0px;
text-align:left;
}
.Upload_img {
width:expression(document.body.clientWidth > 100? "100px": "auto" );
cursor:pointer;
}
-->
</style>
<script language="javascript" src="../js/jquery.js"></script>
<script language="Javascript">
function minipic(smileface){
window.opener.document.form1.minipic.value=smileface;
}
function pic(smileface){
window.opener.document.form1.pic.value=smileface;
}
function SizeChange(obj){
if (obj.style.width == "500px"){
obj.style.width='100px';
parent.document.all['ifrName'].style.height='75px';
obj.alt='点击放大';
}
else{
obj.style.width='500px';
parent.document.all['ifrName'].style.height='350px';
obj.alt='点击缩小'
}
}
function ReUpload(FileName,op){
$.get(
"Upload2.asp?FileName="+FileName+"&op="+op,
function(ReText){
if (ReText.search("成功")>0){
//alert(ReText);
frames.location.href='UploadFile2.asp';
}
else
alert("系统错误,请重新上传!")
location.href="UploadFile2.asp";
}
)
}
function ShowImg(ImgSrc){
var ImgBox = document.getElementById("ImgBox");
var ImgCmd = document.getElementById("ImgCmd");
parent.document.all['ifrName'].style.height='75px';
ImgBox.innerHTML = "<img class='Upload_img' src='../images/upload/"+ImgSrc+"' alt='点击放大' onclick='SizeChange(this);' />";
ImgCmd.innerHTML = "取消";
ImgCmd.href = "javascript:HiddenImg('"+ ImgSrc +"')";
}
function HiddenImg(ImgSrc){
var ImgBox = document.getElementById("ImgBox");
var ImgCmd = document.getElementById("ImgCmd");
parent.document.all['ifrName'].style.height='22px';
ImgBox.innerHTML = "";
ImgCmd.innerHTML = "查看";
ImgCmd.href = "javascript:ShowImg('"+ ImgSrc +"')";
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#D2E4FC">
<%
if request.QueryString("option")<>"" then
if request.QueryString("ImgFile")<>"" then
response.Write("<img src=""../images/upload/"&request.QueryString("ImgFile")&""" style=""width:150px;"" onclick=""SizeChange(this);"" />[<a href=""UploadFile2.asp"">重新上传</a>][<a href=""javascript:ReUpload('"&request.QueryString("ImgFile")&"',"&session("ArticleId")&")"">删除图片</a>]")
response.End()
else
response.Redirect("UploadFile2.asp")
end if
end if
%>
<%
set upload=new upload_DX
set file=upload.file("sf_upfile")
if file.fileSize<1 then
response.Write"<script language=javascript>alert('您没有选择文件:\n\n-----请点击浏览按钮,从弹出的窗口中选择要上传的文件。\n\n-----然后点击上传按钮就可以把文件上传了。\n\n-----不过要注意上传文件的格式哦。');history.back()</script>"
response.End
end if
if file.fileSize<10 or file.fileSize>10*1024*1024 then '-------修改默认的数值 100 单位(KB)-----
response.Write "错误:上传的文件大小超过了限制! <a href='javascript:history.go(-1)'>退回上一步</a>"
response.End
end if
upfilename = split(file.FileName,".")
upfileext = lcase(upfilename(ubound(upfilename)))
'lcase
'UCase
'------------在下面设置上传文件类型,增加( and upfileext<>"文件类型" )----------
if upfileext<>"jpg" and upfileext<>"gif" then
response.Write "<div style=""line-height:25px;"">错误:上传的文件格式不对! <a href='javascript:history.go(-1)'>退回上一步</a></div>"
response.end
end if
'ufp=file.FileName
randomize
NowDm = Now()
ufp=Year(NowDm)&Right("0"&Month(NowDm),2)&Right("0"&Day(NowDm),2)&Right("0"&hour(NowDm),2)&Right("0"&minute(NowDm),2)&Right("0"&second(NowDm),2)&right("00000"&fix(Rnd *100000),5)&"."&upfileext
'检查文件是否已经存在
set myobj=server.CreateObject("Scripting.FileSystemObject")
if myobj.FileExists(server.MapPath("../images/upload/"&ufp&"")) then
call ShowErr("文件名重复,请修改文件名后再上传!","1")
response.end
end if
set myobj=nothing
' sql="select * from [Picture] where picture_url='"&ufp&"'"
' rs.open sql,conn,1,3
' if not rs.eof then
' call ShowErr("文件名重复!","1")
' else
' rs.addnew
' rs("picture_url")=ufp
' rs("picture_addtime")=year(Now())&"-"&month(Now())&"-"&day(Now())
' rs.update
' rs.close
' end if
session("UploadFile")=ufp
file.saveas Server.mappath("../images/upload/"&ufp)
set file=nothing
set upload=nothing
response.Write "文件上传成功,文件名:"&session("UploadFile")&"[<a href=""javascript:ReUpload('"&session("UploadFile")&"',0);"">重新上传</a>]<span id='ImgBox'></span>[<a id='ImgCmd' href=""javascript:ShowImg('"& session("UploadFile") &"');"">查看</a>]"
response.Write ""
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -