#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0

    ASP VBScript Replace


    I messed up an upload routine so that the full physical path to the file is entered into the table on upload. To view the file I need to strip these characters when they exist but folder name is dynamic according to username.

    So the path to the file is /server/plans/directory/uploads/<%=rs_plan.Fields.Item("pl_username")%>/filename

    From this I need to display just the file name.

    Any help would be appreciated.
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Wouldn't it be better to fix the data in the table? So you don't have to deal with it ever again?

    Comments on this post

    • duval agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0
    Yes, I have fixed the upload page so that it just stores the file names so all records added to this point will display correctly. As there have been about 200 records added with the faulty file path, the username is the folder in which files are contained, there are up to four uploads per record, it seems that it would be easier to just clip these if possible.
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Until you have to deal with those names in another place. It's great that you fixed the source of the problem, but I'm saying wouldn't it be easier to fix those records so you don't have to make any more code changes? So you don't have to remember that there are 200 records that don't fit in with the scheme used by every other record?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0
    Updating the table manually but it is rather cumbersome. Thanks again for the feedback and if the solution on the display is simple it would be helpful.
  10. #6
  11. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Well, I tried.

    You have "/server/plans/directory/uploads/something/filename" and you want just "filename"? I'm thinking the easiest method is Mid + InstrRev.
    Code:
    Mid(val, InstrRev(val, "/") + 1)
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0
    Thank you... will continue to edit the records directly and give that a go so that folks don't get tripped up in the itnerim.

    Thanks again, Scott

IMN logo majestic logo threadwatch logo seochat tools logo