problems with file directory ftp - html

i'm new in using hosting, i have a question about a FTP, why if i upload something (for example a image) to my server i cannot see it from the browser using the directory for example (http://www.mywebsite.com/public_html/images/backgrounds/background.png) if i use that address i get a fil with a "?" sign instead of the image. the only way to see the image is changing http by ftp for example,(ftp://ftp.mywebsite.com/public_html/images/backgrounds/background.png)
please how to find the files with http instead of ftp, to be able to use it in my web page using html
thank you

Typically, the publichtml folder is the root of your domain, which is to say that http://www.mywebsite.com/ points to your/relative/path/to/publichtml/
Using your example of putting a file at /publichtml/images/backgrounds/background.png would mean it should be accessible at http://www.mywebsite.com/images/backgrounds/background.png
Similarly, if you put filename.html in the /publichtml/ folder of your server, you should be able to access it at http://www.mywebsite.com/filename.html - If you put it in a subfolder of /publichtml/, say, at publichtml/example/, it should be accessible at http://www.mywebsite.com/example/filename.html
This can very from one server to another, but in most situations, this is common practice.
Edit: broken formatting.

Related

server not reading css and js files

I have created a website using css, js and jquery, and everything works fine on my local machine, but after uploading it to the server, it was only reading the index.html file, leaving out the css and js. Below you can see the website's structure, after being uploaded to the server, on FileZilla.
enter image description here
I have decided to delete everything, re-check the paths and upload them again, but now all I get is a "403 Forbidden" message, saying that "You don't have permission to access / on this server."
Check file permissions of all the files.
Triple check file paths
/www/style.css
./www/style.css
^ Notice this dot
The above are two completely differnet paths. My guess is, that the second one is the correct one and should lead to style in your specific example

How to show image from FTP server in web page [duplicate]

I have a folder in my ftp server which contains several images. I'm trying to access and show these images in a webpage like
<img src="ftp://my_ftp_ip_address/Images/imagename.jpg"/>
But it asks for an FTP username and password. How can I achieve this? Also is it possible to do the same using JSP?
With the latest versions of web browsers (Chrome 59, Firefox 61), you cannot even use ftp:// URL to retrieve an image. And it was never a good solution anyway.
The correct solution is to route the image through your webserver, hiding away not only the credentials, but also the original source of the image.
Create a script (PHP or any other you use) that acts as an image source (you will use it in the <img src=...> attribute. The script will "produce" the image by downloading it from the FTP server.
The most trivial way to implement such a script in PHP (say image.php) is:
<?
header('Content-Type: image/jpeg');
echo file_get_contents('ftp://username:password#ftp.example.com/path/image.jpg');
(you need to URL-encode the credentials, if they contain reserved symbols – you can use urlencode).
And then you use it in the HTML like:
<a src="image.php" />
(assuming the image.php is in the same folder as your HTML page)
The script uses FTP URL wrappers. If that's not allowed on your web server, you have to go the harder way with FTP functions. See
PHP: How do I read a file from FTP server into a variable?
Though for a really correct solution, you should provide some HTTP headers related to the file, like Content-Length, Content-Type and Content-Disposition. For this, see Download file via PHP script from FTP server to browser with Content-Length header without storing the file on the web server.
In practice, you will likely have more images, so you will not have the file name hard-coded in the script, but the script will take the name as a parameter.
See List and download clicked file from FTP
You are telling the browser to access the images using the ftp protocol, this is why it is trying to login.
Change ftp:// to http:// (or https:// if using ssl) to access the images.
You can offcourse also add the username and password to the image, but this way everyone can look at your code and login to your ftp server... not really secure ;)
You can try to modify your src attribute like this:
<img src="ftp://username:password#my_ftp_ip_address/Images/imagename.jpg"/>

Uploading an XAMPP subfolder to a web server

I'm completely new to XAMPP, and don't know much more than HTML and CSS. I've put my website into a subfolder in htdocs called test. In my HTML, I have relative links that look like /test/path/to/image.jpg.
I was planning on uploading the subfolder test to a server using FTP. My question is, will I encounter any problems because of the way I have my links formatted? When my website is live, I'd like for the URL to look more like example.com/path/to/image.jpg rather than example.com/test/path/to/image.jpg. Is it better to use ../ to define my paths instead?
I've seen some similar questions that required people to use the .htaccess file, but I can't find that/don't know how to use it. Again, sorry for my total lack of knowledge on this; I'd be super grateful for any help.
/test/path/to/image.jpg
Isn't a relative path/link - it is absolute, meaning the web server would try to serve the file from http://www.example.com/test/path/to/image.jpg. If you would like that file to be served using a relative URL, you should use:
path/to/image.jpg
Which will serve the file relative to the page that is requesting it. If the requesting page is in the test directory, and document root is the test directory, the server would deliver http://www.example.com/path/to/image.jpg.

How can I simply expose local .html files via web browser using an application server (Glassfish)?

Lets say I have a directory of .html files, accessible by the app server, and I want to display to users so they can access them with their browser:
/import/tps-reports/index.html
/import/tps-reports/report1.html
/import/tps-reports/report2.html
Is there a way I can expose the tps-reports directory to do this so that a user can access them via:
http://www.example.com/tps-reports/index.html
http://www.example.com/tps-reports/report1.html
Also, keep in mind that index.html may reference the other pages:
Report 1
So those links need to work as well.
Here is a possible answer:
http://docs.oracle.com/cd/E19776-01/820-4496/geqpl/index.html
You can set up an alternate doc root so that certain URI patterns point to different paths.
The examples are only really showing relative paths though...I wonder if its "ok" to use this to reference local file systems.

threepenny-gui - opening files

Dear Haskell community I have written my first gui application and decided to use
threepenny-gui to do so.
The task is the following search the files in a given folder for matches and provide links to open those files. In addition I made nice parse and render function as the files (mostly) have a special formatting.
But now I have stumbled upon a problem - most browsers prohibit links to local files by href="file://localhost/home/user/folder/file.pdf" being opened, for security reasons, which I do understand and find completely sensible.
I tried to use href="./file.pdf" when the program and the file are in the same folder, which also doesn't seem to work.
The code of the whole application is available at github/epsilonhalbe, I run it in a folder and access it via a browser at localhost:100000
The HTTP server provided by threepenny-gui will serve up static content from the directory you specify in tpStatic. Put your files in that directory, and make your links' paths be relative to it, and you'll be good to go!
As of threepenny-gui-0.4.*, there are also two functions loadFile and loadDirectory that can be used to serve a local file or directory at an automatically generated URL. This can be useful if the tpStatic field is not enough.