تشارك هذه المقالة بشكل أساسي رمز الوظيفة لاستبدال ASP وحفظ الصور عن بُعد.
يستخدم ASP وظائف لاستبدال الصور عن بُعد وحفظها ، وإكمال وظائف جمع الصور واستخراجها تلقائيًا ، والحكم تلقائيًا على تكرار الصور في الوظيفة ، وتحليل مسار الارتباط بذكاء ، وتحويلها إلى عنوان صورة نسبي وحفظه في دليل الموقع المحدد. في الوقت نفسه ، يعد هذا الرمز أيضًا وظيفة معالجة مهمة في برنامج المجموعة.
- FunctionReplacesavereMoteFile (Const ، Strinstalldir ، Strchanneldir ، Savetf ، Tisturl)
- ifconstr = $ false $ orconstr = orstrinstalldir = orstrchanneldir = ثم
- استبدال avereMoteFile = constr
- exitfunction
- Endif
- DimTempstr ، TempStr2 ، TempStr3 ، Re ، Matches ، Match ، Temppi ، Temparray ، Temparray2
- setre = newregexp
- re.ignorecase = صحيح
- re.global = صحيح
- re.pattern =]>
- setMatches = re.execute (const)
- foreachMatchinMatches
- iftempstr <> ثم
- TEMPSTR = TEMPSTR & $ ARRAY $ & match.value
- آخر
- tempstr = match.value
- Endif
- التالي
- iftempstr <> ثم
- Temparray = Split (TempStr ، $ Array $)
- tempstr =
- Fortempi = 0Toubound (Temparray)
- re.pattern = src/s*=/s*.+؟/.
- setMatches = re.execute (temparray (tempi))
- foreachMatchinMatches
- iftempstr <> ثم
- TEMPSTR = TEMPSTR & $ ARRAY $ & match.value
- آخر
- tempstr = match.value
- Endif
- التالي
- التالي
- Endif
- iftempstr <> ثم
- re.pattern = src/s*=/s*
- tempstr = re.replace (tempstr ،)
- Endif
- setMatches = لا شيء
- setre = لا شيء
- iftempstr = orisnull (tempstr) = truethen
- استبدال avereMoteFile = constr
- exitfunction
- Endif
- tempstr = استبدال (tempstr ،،)
- tempstr = استبدال (tempstr ، '،)
- tempstr = استبدال (tempstr ،،)
- dimremotefileurl ، SavePath ، Pathtemp ، dtnow ، strfilename ، strfiletype ، arrsavefilename ، rannum ، arr_path
- dtnow = الآن ()
- IFSAVETF = truethen
- SavePath = Strchanneldir &/& Year (dtnow) & right (0 والشهر (dtnow) ، 2) و/
- Response.write Rink Path: & SavePath &
- arr_path = split (SavePath ،/)
- pathtemp =
- Fortempi = 0Toubound (ARR_PATH)
- iftempi = 0then
- pathtemp = arr_path (0) و/
- elseiftempi = ubound (arr_path) ثم
- الخروج
- آخر
- pathtemp = pathtemp & arr_path (tempi) و/
- Endif
- ifcheckdir (pathtemp) = falsethen
- ifmakenewsdir (pathtemp) = falsethen
- savetf = خطأ
- الخروج
- Endif
- Endif
- التالي
- Endif
- "إزالة الصور المكررة
- Temparray = Split (TempStr ، $ Array $)
- tempstr =
- Fortempi = 0Toubound (Temparray)
- IFINST (LCASE (TEMPSTR) ، LCASE (Temparray (Temppi))) <1th
- Tempster = TempStr & $ Array $ & Temparray (Temppi)
- Endif
- التالي
- Tempster = يمين (Tempstr ، Len (TempSt) -7)
- Temparray = Split (TempStr ، $ Array $)
- "تحويل عنوان الصورة النسبية
- tempstr =
- Fortempi = 0Toubound (Temparray)
- TempStr = TempStr & $ Array $ & definiteUrl (Temparray (Temppi) ، tisturl)
- التالي
- Tempster = يمين (Tempstr ، Len (TempSt) -7)
- tempstr = استبدال (tempstr ، chr (0) ،)
- temparray2 = split (tempstr ، $ $ $)
- tempstr =
- استبدال الصورة/حفظ
- setre = newregexp
- re.ignorecase = صحيح
- re.global = صحيح
- Fortempi = 0Toubound (Temparray2)
- RemoteFileUrl = temparray2 (tempi)
- ifremotefileurl <> $ false $ andsavetf = truethen'save صورة
- Arrsavefilename = split (RemoteFileurl ،.)
- strfiletype = lace (arrsavefilename (ubound (arrsavefilename))) 'نوع الملف
- ifstrfileType = aspoStrfileType = asaorstrfileType = aspxorStrfileType = cerorstrfileType = cdxorstrfileType = exeOrstRfileType = raroStrfileType = zipthen
- التحميل =
- استبدال avereMoteFile = constr
- exitfunction
- Endif
- عشوائي
- rannum = int (900*rnd) +100
- strfilename = year (dtnow) & right (0 والشهر (dtnow) ، 2) واليمين (0 و day (dtnow) ، 2) واليمين (0 و hour (dtnow) ، 2) & relite (0 & minute (dtnow) ، 2) & right (0 & second (dtnow) ، 2 ) & Right (0 & Second (dtnow) ، 2) & Rannum &. & StrfileType
- re.pattern = temparray (tempi)
- ifSavereMoteFile (SavePath & Strfilename ، RemoteFileUrl) = truethen
- '************************************
- Pathtemp = SavePath & Strfilename
- const = re.replace (connt ، pathtemp)
- re.pattern = strinstalldir & strchanneldir و/
- UploadFiles = UploadFiles & | & re.replace (SavePath & Strfilename ،)
- آخر
- pathtemp = RemoteFileurl
- const = re.replace (connt ، pathtemp)
- 'UploadFiles = UploadFiles & | & RemoteFileurl
- Endif
- elseifremotefileurl <> $ false $ andsavetf = falsethen 'لا يحفظ الصورة
- re.pattern = temparray (tempi)
- const = re.replace (connt ، RemoteFileUrl)
- UploadFiles = UploadFiles & | & RemoteFileUrl
- Endif
- التالي
- setre = لا شيء
- ifuploadfiles <> ثم
- UploadFiles = Right (UploadFiles ، Len (UploadFiles) -1)
- Endif
- استبدال avereMoteFile = constr
- الوظيفية
الوصف المعلمة الوظيفية:
Const: السلسلة لاستبدالها
المعلمات: SavetF: ما إذا كان لحفظ الملف ، FALSE لا يحفظ ، حفظ صحيح
المعلمات: Tisturl: عنوان صفحة الويب الحالي
ما سبق هو رمز استبدال ASP وحفظ وظيفة الصورة عن بُعد ، وآمل أن يكون ذلك مفيدًا لتعلم الجميع.