ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 10th, 2012, 01:04 AM
divya_ divya_ is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 6 divya_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 13 sec
Reputation Power: 0
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
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")

' Map the logical path to the physical system path
Dim Filepath
Filepath = Server.MapPath(Filename)

if FSO.FileExists(Filepath) Then

' Get a handle to the file
Dim file
set file = FSO.GetFile(Filepath)

' Get some info about the file
Dim FileSize
FileSize = file.Size

Response.Write "<p><b>File: " & Filename & " (size " & FileSize &_
" bytes)</b></p><hr>"
Response.Write "<pre>"

' Open the file
Dim TextStream
Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)

' Read the file line by line
Do While Not TextStream.AtEndOfStream
Dim Line
Line = TextStream.readline

' Do something with "Line"
Line = Line & vbCRLF

'Response.write Line
sOutput = sOutput&Line
Loop


'Response.Write "</pre><hr>"

Set TextStream = nothing

Else

Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"

End If

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
response.Write(match&"<br>")
next

%>

Reply With Quote
  #2  
Old May 21st, 2012, 01:14 AM
ronaldstanley ronaldstanley is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 5 ronaldstanley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 8 m 51 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > How to change src of img in html file

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap