How to change src of img in html file
I have a page using which a user can upload a html file in his account to send it as a mailer to others. I need help to detect images on html file and replace the src of each to absolute path. I have regex to detect the img tab but not able to detect src value
Filename = "albmailer.html" ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' Create a filesystem object
set FSO = server.createObject("Scripting.FileSystemObject")
' Map the logical path to the physical system path
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
' Get a handle to the file
set file = FSO.GetFile(Filepath)
' Get some info about the file
FileSize = file.Size
Response.Write "<p><b>File: " & Filename & " (size " & FileSize &_
' Open the file
Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)
' Read the file line by line
Do While Not TextStream.AtEndOfStream
Line = TextStream.readline
' Do something with "Line"
Line = Line & vbCRLF
sOutput = sOutput&Line
Set TextStream = nothing
Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"
Set FSO = nothing
sPattern = "<img[^>]*>"
sPattern = "\<img\s[^\>]*?src=[""']([^""']*?\.(jpg|jpeg|bmp|gif|png)(\?[^""']*)?)[""'][^\>]*\>"
set objReg = new regexp
objReg.Pattern = sPattern
objReg.IgnoreCase = true
objReg.Global = true
set sMatch = objReg.Execute(sOutput)
for each match in sMatch
I am also waiting for the reviews for the same topics and now i got the some information from your post. So, Please keep sharing your Discussion. Thanks.