ASP uses functions to implement substitution, save the remote picture, complete the automatic collection of pictures, extract the image function, the function automatically judge the duplicate picture, intelligent analysis link path, and turned into a relative picture address saved in your designated Site directory, we can use this function in the background editor, When you copy the content that contains the picture, this code will automatically help you upload the image. At the same time, this code is also an important processing function in the acquisition program, the function code is as follows:
Function replacesaveremotefile (constr,strinstalldir,strchanneldir,savetf,tisturl) If constr= "$False $" or ConStr= "" or strinstalldir= "" or strchanneldir= "" Then replacesaveremotefile=constr Exit Function end If Dim tempstr,tempstr2,temps Tr3,re,matches,match,tempi,temparray,temparray2 Set Re = New Regexp Re.ignorecase = True Re.global = True Re.pattern = "]&G
t; " Set matches =re.execute (CONSTR) for all Match in matches If tempstr<> "" Then Tempstr=tempstr & "$Array $" &
Match.value Else Tempstr=match.value End If Next if tempstr<> "" Then temparray=split (TempStr, "$Array $") tempstr= "" For tempi=0 to Ubound (temparray) Re.pattern = "src\s*=\s*.+?\. (Gif|jpg|bmp|jpeg|psd|png|svg|dxf|wmf|tiff) "Set matches =re.execute (Temparray (tempi)) for all Match in matches If
Tempstr<> "" Then Tempstr=tempstr & "$Array $" & match.value Else Tempstr=match.value End If Next next End If If tempstr<> "" "Then Re.pattern =" src\s*=\s* "Tempstr=re.replace (TempStr," ") End If Set MaTches=nothing Set re=nothing if tempstr= "" or IsNull (tempstr) =true Then replacesaveremotefile=constr Exit function End If Tempstr=replace (TempStr, "" "", "") Tempstr=replace (TempStr, "", "") Tempstr=replace (TempStr, "", "") Dim Remotefileurl,
Savepath,pathtemp,dtnow,strfilename,strfiletype,arrsavefilename,rannum,arr_path DtNow=Now () If SaveTf=True Then Savepath= Strchanneldir & "/" & Year (Dtnow) & Right ("0" & Month (Dtnow), 2) & "/" Response.Write "link path : "& Savepath &" Arr_path=split (Savepath, "/") pathtemp= "for Tempi=0 to Ubound (arr_path) If tempi=0 Then Pathte Mp=arr_path (0) & "/" ElseIf Tempi=ubound (Arr_path) Then Exit for Else pathtemp=pathtemp & Arr_path (tempi) & "/ "End If If Checkdir (pathtemp) =false Then If makenewsdir (pathtemp) =false Then savetf=false Exit for End If End if Next end If ' Remove duplicate picture temparray=split (TempStr, "$Array $") tempstr= "" For Tempi=0 to Ubound (temparray) If Instr (Lcase (TEMPSTR), Lcase (Temparray (TEMPI)) <1 Then Tempstr=tempsTR & "$Array $" & Temparray (tempi) End If Next tempstr=right (Tempstr,len (TEMPSTR) -7) temparray=split (TEMPSTR, "$ array$ ")" Convert relative picture address tempstr= "for tempi=0 to Ubound (temparray) Tempstr=tempstr &" $Array $ "& Definiteurl (Temparra Y (tempi), Tisturl) Next tempstr=right (Tempstr,len (TEMPSTR) -7) tempstr=replace (TEMPSTR,CHR (0), "") Temparray2=split ( TempStr, "$Array $") tempstr= "" ' Picture replacement/save Set Re = New Regexp Re.ignorecase = True Re.global = True for tempi=0 to Ubound (Tem PArray2) Remotefileurl=temparray2 (tempi) If remotefileurl<> "$False $" and savetf=true Then ' save picture Arrsavefilename =
Split (Remotefileurl, ".") Strfiletype=lcase (Arrsavefilename (Ubound (arrsavefilename)) ' File type If strfiletype= ' asp ' or strfiletype= ' ASA ' or Strfiletype= "aspx" or strfiletype= "CER" or strfiletype= "CDX" or strfiletype= "EXE" or strfiletype= "rar" or "strfiletype=" Zip "then uploadfiles=" "Replacesaveremotefile=constr Exit Function end If Randomize rannum=int (900*rnd) +100 Strfilenam E = year (Dtnow) & Right ("0 "& Month (Dtnow), 2) & Right (" 0 "& Day (Dtnow), 2) & Right (" 0 "& Hour (Dtnow), 2) & Right (" 0 "& mi Nute (Dtnow), 2 & Right ("0" & Second (Dtnow), 2) & Rannum & "." & Strfiletype Re.pattern =temparray (tempi ) If Saveremotefile (Savepath & strfilename,remotefileurl) =true Then ' ******************************** PathTemp=
Savepath & strFileName Constr=re.replace (constr,pathtemp) Re.pattern=strinstalldir & StrChannelDir & "/" Uploadfiles=uploadfiles & "|" & Re.replace (Savepath &strfilename, "") Else Pathtemp=remotefileurl ConStr= Re.replace (constr,pathtemp) ' Uploadfiles=uploadfiles & "|" & Remotefileurl end If ElseIf remotefileurl<> " $False $ "and savetf=false Then" Do not save picture Re.pattern =temparray (tempi) constr=re.replace (constr,remotefileurl) uploadfiles =uploadfiles & "|" & Remotefileurl End If Next Set re=nothing If uploadfiles<> "" Then uploadfiles=right (Uplo Adfiles,len (Uploadfiles)-1) End If ReplacesavereMotefile=constr End Function
Function parameter Description:
Constr: The string to replace
Parameters: SAVETF: Save file, False not save, true save
Parameters: Tisturl: Current Web page address
The above is ASP replacement, save remote picture function code, I hope to help you learn.