Results 1 to 5 of 5

Thread: [RESOLVED] Have problem with url and file://

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Resolved [RESOLVED] Have problem with url and file://

    Hi!

    I want in ASP generate urls on a web page that point to locally stored files, like a file browser. I build the paths in visual basic code on the server.

    The problem is that files with a space in them refuses to encode correctly.

    I generate the code like this:

    Code:
     <td><a href=<%= Replace("file://" + path + "\" + Filename, " ", "%20") %>><%= Filename %></a></td>
    With the above code the url (when right click in IE and select properties) looks fine but the %20 has been replaced with %2520. I understand that something is trying to encode the % character.

    When I skip the Replace call and do something like this for a file with name "first text.txt":
    Code:
     <td><a href=<%= "file://" + path + "\" + Filename %>><%= Filename %></a></td>

    I get an url like file://mypath\myfolder\first

    here this "something" that encodes the % doesn't care about the spaces.

    Filename above is a string from the "scripting.filesystemobject" library.


    Basically, I want to write an url that points to a file on the local network. I know there are much better ways to do this, but this is a really old asp app, and this is a small new feature that was requested. And I have everything working except this rendering of the actual urls. For folders, the Replace(folder, " ", "%20") works fine for some reason.

    HELP!

    /Henrik

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Have problem with url and file://

    Should I move this to the ASP classic forum?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Have problem with url and file://

    Quote Originally Posted by dday9 View Post
    Should I move this to the ASP classic forum?
    Yes.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Have problem with url and file://

    Quote Originally Posted by dclamp View Post
    Yes.
    Although, how can you be sure the original poster is using asp and not asp.net? Just because the original poster has written asp that he is not in fact referring to asp.net.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: Have problem with url and file://

    Hi!

    My mistake, I assumed this part of the forum was for asp classic and vbscript.
    I solved it by putting " around the path, seem to work like when you are typing paths with spaces in the command prompt or executing a batch script.

    Problem solved.

    /Henrik

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width