473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

file path ?

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

to download it the path should be

http://3.212/232/abc/def/upload/contents.doc

how do i go about it ?
i am saving the file by using
Expand|Select|Wrap|Line Numbers
  1.  o.FileFullPath = Server.MapPath(".") & "\upload\"  & sFile 
from a script i downloaded
Apr 2 '09 #1
6 2403
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:

Expand|Select|Wrap|Line Numbers
  1. '''Using static sFile value for demonstration purposes
  2. sFile = "contents.doc"
  3.  
  4. '''Get server file path
  5. str_fullPath = Server.MapPath(".") & "\upload\"  & sFile
  6.  
  7. '''Set the www prefix
  8. str_httpPath = "http://3.212/232"
  9.  
  10. '''Remove localhost routing portion of the file path returned from Server.MapPath
  11. '''First line creates a two value array, the local host portion is the 0 index and we
  12. '''don't want that, so we use the 1 index of the str_httpPathProc array created by
  13. '''the Split function
  14. str_httpPathProc = split(str_fullPath,":")
  15.  
  16. '''Correct slash direction for www routing
  17. str_httpPathProc1 = Replace(str_httpPathProc(1),"\","/")
  18.  
  19. '''Concatenate the www prefix the with processed file path
  20. str_httpPath = str_httpPath & str_httpPathProc1
  21.  
  22. '''Write out our new file path. You can use this path as the href value to create
  23. '''links to files on the server
  24. Response.write str_httpPath
  25.  
  26.  
Hope that's what you were after. There are more complex methods, but this should get your started.


Best Regards,
Jenkins
Apr 4 '09 #2
@jenkinsloveschicken
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.variables be okay ?
Apr 5 '09 #3
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
Apr 5 '09 #4
@jenkinsloveschicken
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.....
Apr 6 '09 #5
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:

http://bytes.com/groups/asp/126721-u...rver-urlencode

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


Hope this helps

Cheers,
Jenkins
Apr 8 '09 #6
hey
just putting the link in double quotes solved the problem...
thanks...
Apr 9 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: chris | last post by:
I'm writing a small app to help me learn more about cryptography. All it does is encrypt all of the files in directory A, and put the encrypted versions of the files in directory B. It then...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
6
by: Alex Chan | last post by:
Hi Group, I encountered something strange with File.Exists(string path). This function is simply to check whether a file exists in certain path. However, if the path starts with "file:\" in the...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
5
by: Eugene Anthony | last post by:
ds1.Tables.Rows.ItemArray.GetValue(0).ToString() contains the string path: images/5/Video1/qbert.flv if (File.Exists(ds1.Tables.Rows.ItemArray.GetValue(0).ToString())) { //code to execute } ...
2
by: JohnLorac | last post by:
Hello, I'm trying to load and write file on local disc drive using signed javascript file. But I have experienced problem running this url: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.