Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

ASP VbScript Replace

Dear Experts

I am displaying the value from a database field on a webpage.  

The field I am displaying is via the code <%=RTRIM(images.Fields.Item("docfilename").Value)%>

If the value of the field displayed above was 'filename.jpg'  - I am looking for a way to be able to display this as 'filename_small.jpg'

Basically I need to try and find a way of inserting '_small' to the value before the '.jpg'

Can anyone offer any advise on how to achieve this?

1 Solution
käµfm³d 👽Commented:

<%=Replace(RTRIM(images.Fields.Item("docfilename").Value), ".jpg", "_small.jpg")%>

Open in new window

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Do you want to display it as a link using a different name like <a href="<%=RTRIM(images.Fields.Item("docfilename").Value)%>"> <%=replace(RTRIM(images.Fields.Item("docfilename").Value),".jpg","_small.jpg")%>

or do you want to actually change the file name with fso

    set fso = CreateObject("Scripting.FileSystemObject")
    set file = fso.GetFile("c:\website\images\imagname.jpg")
    file.name = "c:\website\images\imagname_small.jpg"
    set file = nothing
    set fso = nothing

Then later on you can access the file <img src="/images/imagename_small.jpg">

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now