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

📄 enproductmanageeditsave.asp

📁 这个也是一个功能强大的企业整站的ASP源代码
💻 ASP
字号:
<!--#include file="../include/connstr.asp"-->
<!--#include file="../Include/CnpvUpFile.inc"-->
<!--#include file="../include/DefFunction.asp"-->
<%
 dim upload,file1,file2,formName,formPath,T_comment,fso
 set upload=new upload_5xSoft ''建立上传对象
 
 if not isdate(upload.form("T_AddTime")) then
   response.write "<script>alert('错误的时间格式,请重新填写!');history.back();</script>"
   response.end
 end if

 set rs_oldFile=conn.execute("select * from tenProduct where ID="&upload.form("EditID")) '把原来的产品图片读出来,以便更换删除
 OldProductPic=rs_oldFile("ProductPic")
 OldOtherFile=rs_oldFile("OtherFile")
 
 FileName1=OldProductPic
 FileName2=OldOtherFile
 
 set file1=upload.file("T_ProductPic")  ''生成一个文件对象
 set file2=upload.file("T_OtherFile") 
 
 if trim(file1.FileName)<>"" or trim(file2.FileName)<>"" then 
   if file1.FileSize>200000 then 
     response.write "<script>alert('产品图片不能大于200K!');history.back();</Script>" 
     response.End()
   else if file2.FileSize>1000000 then
           response.write "<script>alert('详细资料不能大于1M!');history.back();</Script>" 
           response.End()   
		 else						                         	   
            formPath="/UploadFile/ProductFile"'得到上传目录
		    if right(formPath,1)<>"/" then formPath=formPath&"/"  ''在目录后加(/)					 
					  
            if file1.FileSize>0 then '如果有产品图片存在,保存判断是否要删除原先的图片
			  FileName1=makefilename()&"_Pic."&GetExtendName(file1.FileName)
			  file1.SaveAs Server.mappath(formPath&FileName1)			  
 		      if (OldProductPic<>"") then
                 delfname=server.mappath(formPath) & "\" & OldProductPic
                 set TestFileObject=Server.Createobject("Scripting.FileSystemObject")
                 if  TestFileObject.FileExists(delfname) then
                    set NewFile=TestFileObject.getfile(delfname)
                    Newfile.delete
                 end if
              end if   '与删除图片对应
		    end if

            if file2.FileSize>0 then
               FileName2=makefilename()&"_File."&GetExtendName(file2.FileName)
			   file2.SaveAs Server.mappath(formPath&FileName2)
 		       if (OldOtherFile<>"") then
                  delfname=server.mappath(formPath) & "\" & OldOtherFile
                  set TestFileObject=Server.Createobject("Scripting.FileSystemObject")
                  if TestFileObject.FileExists(delfname) then
                     set NewFile=TestFileObject.getfile(delfname)
                     Newfile.delete
                  end if
               end if   '与删除图片对应
			 end if '与file2.FileSize>0对应
		 end if'与判断file2对应
   	  end if '与判断file1对应
  end if '与判断file1,file2是否为空对应

  '--------------------------------------------删除无用的文件或图片
  Set fso = CreateObject("Scripting.FileSystemObject")
  arrUploadFiles=split(upload.form("UploadFile"),"$")
  UploadFile=""
  for intTemp=0 to ubound(arrUploadFiles)
    if instr(upload.form("Content"),arrUploadFiles(intTemp))<=0 then
      strRubbishFile=server.MapPath("/UploadFile/ProductFile/" & arrUploadFiles(intTemp))
      if fso.FileExists(strRubbishFile) then
        fso.DeleteFile(strRubbishFile)
      end if
    else
      if intTemp=0 then
         UploadFile=arrUploadFiles(intTemp)
      else
         UploadFile=UploadFile & "$" & arrUploadFiles(intTemp)
      end if
    end if
  next
 
 set file1=nothing
 set file2=nothing
 conn.execute("update tenProduct set Title='"&MyRequest(upload.form("T_Title"))&"',ProductPic='"&FileName1&"',OtherFile='"&FileName2&"',CateID="&upload.form("S_CateID")&",Price='"&upload.form("T_Price")&"',Content='"&MyRequest(upload.form("Content"))&"',UploadFile='"&UploadFile&"',IsHot="&upload.form("R_IsHot")&",AddTime='"&upload.form("T_AddTime")&"',StateFlag='"&upload.form("R_StateFlag")&"' where ID="&upload.form("EditID"))
 
 response.write "<script>alert('恭喜您,修改已经成功完成!');location.replace('enProductManage.asp?Key="&upload.form("Key")&"&PageNo="&upload.form("PageNo")&"&CateID="&upload.form("CateID")&"&CateName="&upload.form("CateName")&"');</script>"
 set upload=nothing 
 %>

⌨️ 快捷键说明

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