0

I am trying to open a .xls file found under a linux server using a web page, using:

<a href="/tmp/hello.xls">click here</a>

I got a result "resource not found"; however I am sure than it is found under the /tmp directory. Any suggestions please?

Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
roy
  • 33
  • 1
  • 9

2 Answers2

2

That's because when you use href="/tmp/hello.xls", the browser will interpret that as an absolute path relative to the current domain, i.e. http://your_website_domain/tmp/hello.xls, which may not be what you want

If you're targetting /tmp/hello.xls on the client machine

To target a local file, you'll need to specify href="file:///tmp/hello.xls". Unfortunately, that may not work on some browsers which security settings in place which stops the loading of local files from external content.

For more details and a possible workaround, check out this question: How do I make a file:// hyperlink that works in both IE and Firefox?

If you're targetting /tmp/hello.xls on the web server

You cannot directly access a file on the server that's not in the web root.

If you give more details about what you're trying to achieve, we might be able to give more specific advice.

Community
  • 1
  • 1
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
  • hello Shawn chin than a lot for your help but its still not working i try using href="file:///tmp/hello.xls", but as u said it not working i want the users to go to this web page and be able to download this file how can i fix the reference in order to work on any web browser thanks in advance for your help – roy Nov 11 '11 at 14:40
  • Is the file stored in the webserver? – Shawn Chin Nov 11 '11 at 14:44
  • the file is stored in a linux server and my web application is running on jboss unders the same server – roy Nov 11 '11 at 14:53
  • Then you shouldn't be using `file://`. You will have to move the file to a directory that can be served by your webserver. I'm not familiar with jboss, but perhaps this will help: http://docs.jboss.org/jbossas/guides/webguide/r2/en/html/ch08.html – Shawn Chin Nov 11 '11 at 14:58
  • Hey Shawn Chine hope ur doing well, i got that working on Jboss, just wanna ask you if you have any clue or reference to deploy such files under Jetty webserver, because i have to run it over Jetty as well, thanks a lot for your help – roy Nov 14 '11 at 11:08
  • Googling for "jetty static files" gave me http://docs.codehaus.org/display/JETTY/Static+Content and http://docs.codehaus.org/display/JETTY/Newbie+Guide+to+Jetty#NewbieGuidetoJetty-FileServer%2COneHandler – Shawn Chin Nov 14 '11 at 11:15
1

Make sure your path to the xls file is correct via the href link.

student
  • 213
  • 2
  • 5