⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attachpic.asp

📁 用ASP写的电子购物系统
💻 ASP
字号:
<%@ LANGUAGE="VBSCRIPT" %>
<%dim fileup,tfiles,mfiles,totalsize,num
  
 
  '获得文件的后缀名
function getFileExtName(fileName)
	dim pos
	pos=instrrev(filename,".")
	if pos>0 then 
		getFileExtName=mid(fileName,pos+1)
	else
		getFileExtName=""
	end if
end function 
function one_two(one)
        if len(cstr(one))=1 then
           one_two="0"+cstr(one)
        else
           one_two=cstr(one)
        end if   
  end function
function formatdd()
    formatdd=year(date()) & one_two(month(date())) & one_two(day(date())) & one_two(hour(time())) & one_two(minute(time())) & one_two(second(time()))
end function

if request("operation")="open" then
   num=-1
   totalsize=0
   mfiles=";"   
else
    set fileup=server.createobject("ChinaASP.UpLoad")  
    
    for each formField in fileup.Form 
	    if formField.controlName="totalsize" then
	       totalsize=cint(formField.value)     
	    end if
	    if formField.controlName="tfiles" then
	       tfiles=formField.value       
	    end if
	     if formField.controlName="mfiles" then
	       mfiles=formField.value       
	    end if
	next
    for each f in fileup.Files
        if f.isempty=false then
		    tfiles=tfiles & f.FileName & "(" & f.FileSize & " bytes);"
            totalsize=totalsize+formatnumber(f.FileSize/1024,2)
            tempf=session("userid") & formatdd  &"." & getFileExtName(f.fileName)
            f.saveas server.MapPath("./upload") & "\" & tempf
           
            mfiles=mfiles & tempf & ";"
            
        end if
    next
    selfile=split(left(tfiles,len(tfiles)-1),";")
    selvalue=split(mid(mfiles,2,len(mfiles)-2),";")
    num=ubound(selfile)
    'Response.Write tfiles & "*" & num  & "*" &  mfiles
end if     
%>
<html>
<head>
<title>添加图片</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
.f1 {font-family:宋体;font-size:9pt;}
</style>
<script language=javascript>
function submitme() {
if (document.Upload.picfile.value=="" ) alert("上传文件名不能为空!");
else {var p=document.Upload.pics;
      var plen=p.length;
      var selfile="";
      if (plen>=1) {
      for (var i=1;i<plen;i++) selfile=selfile + p.options[i].text + ";";
      document.Upload.tfiles.value= selfile;}
      document.Upload.submit();
      }
}
function delfile() {
var p=document.Upload.pics;
var s=new String();
s=document.Upload.mfiles.value;
var t=";" + p.options[p.selectedIndex].value + ";";
if (p.selectedIndex!=0)
p.options[p.selectedIndex]=null;
document.Upload.mfiles.value=s.replace(t,";")
p.options[0].selected=true;
}
function closeme() {
if (document.Upload.mfiles.value==";") 
  { if (confirm("不添加图片就退出?")) {
         window.opener.news.picfiles.value="";
         window.close();}
   }      
else {
      window.opener.news.picfiles.value=document.Upload.mfiles.value;
      window.close();
   }   
}
function Preview(){
	var url =document.Upload.picfile.value
	if ( url != "")
	{window.open( url );
	}
}
</script>
</head>

<body bgcolor="#FFFFFF">
<form enctype="multipart/form-data" method="post" action="AttachPic.asp" name="Upload">
<table width="400" border="0" cellspacing="0" cellpadding="0" class="f1">
  <tr> 
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr> 
    <td width="330">1、点“Browser”按钮,找到您所要粘贴的图片附件:</td>
    <td width="70"><input type="hidden" name="CopyrightInfo" value="http://www.chinaasp.com"></td>
  </tr>
  <tr> 
    <td width="330"> 
      <input type="file" size="40" name="picfile">
    </td>
    <td width="70"><input type="button" name="preview" onclick="javascript:Preview()" value="预览" class="f1"></td>
  </tr>
  <tr> 
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr> 
    <td width="330">2、选定一幅图片后,点“粘贴”按钮,将该图片贴到稿件上;</td>
    <td width="70"><img src="image/button-paste.gif" width="61" height="21"  style="cursor:hand" onclick="javascipt:submitme()"></td>
  </tr>
  <tr> 
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr> 
    <td width="330">3、如有多幅图片要粘贴,重复1、2步骤;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr> 
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr> 
    <td width="330">4、所有的图片粘贴完毕后,点“确定”按钮返回。</td>
    <td width="70"><img src="image/button-ok.gif" width="64" height="21" style="cursor:hand" onclick="javascript:closeme()" ></td>
  </tr>
  <tr> 
    <td width="330"><input type="hidden" name="mfiles" value="<%=mfiles%>"></td>
    <td width="70"><input type="hidden" name="tfiles" value="<%=tfiles%>"><input type="hidden" name="totalsize" value="<%=totalsize%>"></td>
  </tr>
  <tr> 
    <td width="330">
        <select name="pics">
          <option value="none">--请选择下面的图片--</option>
     <%if num>-1 then
            for i=0 to num %>
                <option value="<%=selvalue(i)%>"><%=selfile(i)%></option> 
     <%     next  
       end if
     %> 
        </select>
      </td>
    <td width="70"><img src="image/button-del.gif" width="61" height="21" onclick="javascript:delfile()"  style="cursor:hand"></td>
  </tr>
  <tr> 
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr>
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
  <tr>
    <td width="330">现在附件文件总量为:<%=totalsize%>K字节 共<%=num+1%>个图片</td>
    <td width="70"></td>
  </tr>
  <tr>
    <td width="330">&nbsp;</td>
    <td width="70">&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -