0

I want load a remote file from a server.

This file is not in a web site. So when I open a file I use

window.open('http://5.135.140.184:8080/tpi/documents/D773.JPG', '_blank'); 

This opens my picture. But if I want to use a complete path, I use

window.open("http://5.135.140.184:8080/var/lib/tomcat/webapps/tpi/documents/D773.JPG", '_blank'); 

In this case I have a 404 error ... How do I do?

P.S.The file D773.JPG is in the path var/lib/tomcat/webapps/tpi/documents

15
  • 2
    Welcome to Stack Overflow! Please take the tour, have a look around, and read through the help center, in particular How do I ask a good question? I'm afraid your question is unclear and contradicts itself. You said "This file is not in a web sites" (sic) but then you said you can access the file via http://5.135.140.184:8080/tpi/documents/D773.JPG, which means it is in a web site. Which is it? Commented May 2, 2018 at 9:32
  • I want load an other file that is not in the web sites... Commented May 2, 2018 at 9:34
  • You can't, via HTTP. Commented May 2, 2018 at 9:34
  • 2
    There's no need to SHOUT. Commented May 2, 2018 at 9:35
  • 1
    different things can happen here, some inconsistencies in the question can make us think that you're trying to access a file that is not accessible (in a computer without server or something likely). If we ignore some of the contradicting points, it can also be that you have a confusion between the server folder directory and what's accessible through an URL (in your case, what's in the folders var/lib/tomcat/webapps/tpi/documents would not be accessible through this exact path by URL, but by tpi/documents). There can be redirecting rules that can affect an URL destination too Commented May 2, 2018 at 9:47

1 Answer 1

3

You can only access things via HTTP that are served by an HTTP (e.g., "web") server which recognizes and handles the URL you give it. It would be possible to configure an HTTP server to allow you to access any file by full path, but it would almost certainly be an extraordinarily bad idea to make **all* files on a machine accessible via HTTP.

Your question contradicts itself by saying both that the file isn't in a web site and that you can access the file via http://5.135.140.184:8080/tpi/documents/D773.JPG. If you can access the file via that URL, then an HTTP server at 5.135.140.184:8080 is running and handles that URL by giving you the file. That's what you should stick with.

In a comment you've added

I want load an other file that is not in the web sites.

You can't, not via HTTP. HTTP requires a web server that understands the URL. If your web server at 5.135.140.184:8080 isn't configured to deliver the file you want, you cannot access it via HTTP (without changing the server configuration).

Sign up to request clarification or add additional context in comments.

3 Comments

Was just typing something similar. +1 Since http://5.135.140.184:8080/var/lib/tomcat/webapps is serving a web directory hence you receive the file via http://5.135.140.184:8080/tpi/documents/D773.JPG
If I use window.open('ftp: //5.135.140.184/var/lib/tomcat/webapps/tpi/documents/D773.JPG', '_blank'); ?
If you have an FTP server set up to expose all of your files via FTP (a Bad Idea™), sure. Or if you have it set up to do file sharing of all your files (a Bad Idea™), you could use a file:/// URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.