file path ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aashishn86
    New Member
    • Mar 2009
    • 51

    file path ?

    i have a file uploaded to my server
    the path is shown as
    E:\abc\def\uplo ad\contents.doc

    to download it the path should be



    how do i go about it ?
    i am saving the file by using
    Code:
     o.FileFullPath = Server.MapPath(".") & "\upload\"  & sFile
    from a script i downloaded
  • jenkinsloveschicken
    New Member
    • Dec 2006
    • 56

    #2
    aashishn86,

    So is your question how do you go about making an href to point to the file? Or are you trying to save the file name with the www address of the file?

    I would suggest that if you are getting the file path and it is correct, then in your output page, you could perform a split on the file path on ":" and then append your www address prefix.

    For example:

    Code:
    '''Using static sFile value for demonstration purposes
    sFile = "contents.doc"
    
    '''Get server file path
    str_fullPath = Server.MapPath(".") & "\upload\"  & sFile
    
    '''Set the www prefix
    str_httpPath = "http://3.212/232"
    
    '''Remove localhost routing portion of the file path returned from Server.MapPath
    '''First line creates a two value array, the local host portion is the 0 index and we
    '''don't want that, so we use the 1 index of the str_httpPathProc array created by
    '''the Split function
    str_httpPathProc = split(str_fullPath,":")
    
    '''Correct slash direction for www routing
    str_httpPathProc1 = Replace(str_httpPathProc(1),"\","/")
    
    '''Concatenate the www prefix the with processed file path
    str_httpPath = str_httpPath & str_httpPathProc1
    
    '''Write out our new file path. You can use this path as the href value to create
    '''links to files on the server
    Response.write str_httpPath
    Hope that's what you were after. There are more complex methods, but this should get your started.


    Best Regards,
    Jenkins

    Comment

    • aashishn86
      New Member
      • Mar 2009
      • 51

      #3
      Originally posted by jenkinsloveschi cken
      aashishn86,

      So is your question how do you go about making an href to point to the file? Or are you trying to save the file name with the www address of the file?

      I would suggest that if you are getting the file path and it is correct, then in your output page, you could perform a split on the file path on ":" and then append your www address prefix.

      For example:

      Code:
      '''Using static sFile value for demonstration purposes
      sFile = "contents.doc"
      
      '''Get server file path
      str_fullPath = Server.MapPath(".") & "\upload\"  & sFile
      
      '''Set the www prefix
      str_httpPath = "http://3.212/232"
      
      '''Remove localhost routing portion of the file path returned from Server.MapPath
      '''First line creates a two value array, the local host portion is the 0 index and we
      '''don't want that, so we use the 1 index of the str_httpPathProc array created by
      '''the Split function
      str_httpPathProc = split(str_fullPath,":")
      
      '''Correct slash direction for www routing
      str_httpPathProc1 = Replace(str_httpPathProc(1),"\","/")
      
      '''Concatenate the www prefix the with processed file path
      str_httpPath = str_httpPath & str_httpPathProc1
      
      '''Write out our new file path. You can use this path as the href value to create
      '''links to files on the server
      Response.write str_httpPath
      Hope that's what you were after. There are more complex methods, but this should get your started.


      Best Regards,
      Jenkins
      that seems to solve my problem
      but what if the server on which the site is hosted changes on a later date...
      once the development is over. the server is likely to be changed...
      i need a permanent solution...
      would getting the server ip from Server.variable s be okay ?

      Comment

      • jenkinsloveschicken
        New Member
        • Dec 2006
        • 56

        #4
        I would imagine that would work as long as the users can hit the IP from a remote machine(no proxy, etc). You can always try it and use the concatenation to build the hrefs.

        Let me know if that works for you.

        Cheers,
        Jenkins

        Comment

        • aashishn86
          New Member
          • Mar 2009
          • 51

          #5
          Originally posted by jenkinsloveschi cken
          I would imagine that would work as long as the users can hit the IP from a remote machine(no proxy, etc). You can always try it and use the concatenation to build the hrefs.

          Let me know if that works for you.

          Cheers,
          Jenkins
          Hi !!
          that works fine for me... except for two problems
          1) a text file opens in the browser itself when i click the link . I want it to be downlaoded
          2) for filenames which have spaces , the name after the space is truncated, so the link doesn't open.....

          Comment

          • jenkinsloveschicken
            New Member
            • Dec 2006
            • 56

            #6
            In response to your inquiries:

            1. Can you provide a sample link? Chancing a guess, it may be browser related(such as server MIME types).

            2. Check out this old post:



            This post talks expressly about the issues encountered when created hrefs to file names with spaces.


            Hope this helps

            Cheers,
            Jenkins

            Comment

            • aashishn86
              New Member
              • Mar 2009
              • 51

              #7
              hey
              just putting the link in double quotes solved the problem...
              thanks...

              Comment

              Working...