HTML local file access - html

I would like to access a local file in the immediate directory
From my understanding, you'd usually have to do something like
file://path/to/file/document.html
which requires the full path, but I would like to do something like
file://./document.html
instead, where ./ represents the current directory reference, so that I do not have to know the directory path nor make any assumptions about it.
is there any trickery like that possible with html file paths?

Use:
document.html
With no protocol specified, and no / for directories, the browser should request the asset from the same directory/folder that the current page is at.

If it's running locally (from that directory), just use ./ without the file://.

try this http://www.nt22.com/html_tutorials/022_html_path.html
using page.html and ./page.html works the same.
../ goes to a lower directory
i.e.
root/www/page.html
if you are in root/stuff/hi.html you can go to the 'www' directory by doing
../www/page.html

Related

Can't change Apache2 shared folder's file

I'd like to change the page that shows what files I've uploaded. I never found the editable file. Can it be changed at all?? I have read a bunch article about this problem but I haven't found the solution.
I am talking about this page: Index of /--
Here is my shared folder: Location
Change the index file (probably: index.html or index.php) or add one yourself, if it does not exist yet. You can use .htaccess for example, if the directory or files inside should be access protected. You can also redirect the user when he is accessing the directory or a file inside.
The images that you have provided show the fallback display of a directory for apache.

image src attribute does not display locally-stored image

I have images stored as png files on the local server and only the filename gets saved to the DB. When rendering images to the client I combine the relative path of the image with the filename from the db as pass it in like so:
<img src='../../public/avatar-pictures/3fVZNShyQRAtBbipvzVrDwDD.png'/>
But it doesn't work. As a last attempt of desperation, I even moved the png file itself to the root directory of the client script and it still produced nothing.
what is causing this issue?
By default, node.js and Express do not serve any files. So, you can't give the browser a path to some location on your server's hard drive and expect the web server to send the files. It does not do that (unlike what people familiar with Apache might expect).
You will need a route on your server that points to the public directory. There are several ways to do it, but here's one:
<img src='/public/avatar-pictures/3fVZNShyQRAtBbipvzVrDwDD.png'/>
Then, on your server, you would use the express.static() middleware to create a route that looks for URLs starting with /public and will serve files from the public directory on your hard drive that match the path of the URL:
app.use("/public", express.static("../../public"));
The path you pass to express.static() needs to point to the public directory on your local hard drive. You don't disclose your local file structure so I can't tell you exactly what that should be. The example above will be relative to the current working directory when your program was started. It is perhaps more common to build the path yourself from the module directory. So, if the public directory is two levels above your module directory, you might do this:
app.use("/public", express.static(path.join(__dirname, "../../public")));
And, then it's wired more specifically to be relative to your module's directory and not dependent upon the current working directory which can be changed by code or by how your program is launched.
You can, of course, also use a fully qualified path:
app.use("/public", express.static(path.join("/someVol/users/me/myProject/public")));
Keep in mind that the express.static() middleware opens up the entire directory tree that you point it at for public access so you have to make absolutely sure that only public things are in there. By default, express.static() does not permit .. in the paths so a request can't get out of the directory you specify.

what kind of attribute does '#' represent in Mac OS

I'm using nginx to build a web server. By default, there is a folder named html, which contains an index.html and a 50.html. If we visit localhost, the index.html in the folder html will be shown.
Now I need to create my own folder containing all of my .html files. But when I configure nginx and try to visit them, I always get an 403 error.
For now I'm considering it's the problem of attributes of .html files.
I've found that the attributes of html folder contain an #, whereas my folder doesn't. I want to know what does it mean and how to add such an attribute for my own folder.
The # signifies that the file has extended permissions attributes beyond the standard U/G/O. It could be related to metadata or quarantine functionality. You can view the attributes by using the xattr command:
xattr file.jpg
You can remove the extended attributes like so:
xattr -d file.jpg
https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xattr.1.html

How to specify paths in JMeter tests installation independent

This description of the CSV Data SetConfig describes that the path to a CSV file used for importing parameters should reside in the bin directory of the JMeter installation, or the path specified should be relative to that bin directory:
Save that file in the bin directory where your JMeter installation lives.
Since the installation path of JMeter is potentially (and in my case actually) different on the various machines involved, this is rather awkward.
What is the preferred way to specify such paths in a way that is independent of the installation directories and the directory the test is stored in?
You can do this:
in your path use __P function
__P(datadir)/file1.csv
When starting JMeter, pass value using -Jdatadir=<your full path to data directory>, see http://jmeter.apache.org/usermanual/get-started.html#override
Turns out that article was wrong. By accident I found out that JMeter seems to consider paths relative to the testscript it has loaded. So no need to put anything in the bin directory of JMeter itself.
Of course if you can't (or don't want) to use relative paths like that either, UBIK LOAD PACKs answer should do the trick.

change folder index to a HTML page within folder

I have seen a few examples with link to folder but i realy don't understant what it is or how to manipulate it or get it to set the specific html page within the folder.
My website is a basic one with only CSS and HTML
it is formatted as
[file]home.html // C:/Users/user/Desktop/mywebsite/home.html
[folder]Order // C:/Users/user/Desktop/mywebsite/order/
↳[file]ordersheet.html // C:/Users/user/Desktop/mywebsite/order/ordersheet.html
I want to try set the folder path C:/Users/user/Desktop/mywebsite/order/ as the file ordersheet.html C:/Users/user/Desktop/mywebsite/order/ordersheet.html how can this be done?
To set /order to ordersheet.html change the name of ordersheet.html to index.html
The index.html is the default file that the server will serve to the visitor when he visits that specific directory.
link text
link text = what you want it to say to the user
/Users/user/Desktop/mywebsite/order/ = directory path
Keep in mind that this will only work locally. If you have it up on a server, visitors don't have access to your full C:/ drive so you have to use relative links, i.e. just /order/
If I remebember correctly, you use something like this:
<a href="file:///C:/Users/user/Desktop/mywebsite/order/ordersheet.html>link to file on harddisk</a>
If you would want to have that anchor to a folder, you would just use this:
<a href="file:///C:/Users/user/Desktop/mywebsite/order/>link to a folder on harddisk</a>
Your browser is operating directly on your system's local filesystem, so you can't.
What you have been looking at is a function of a web server (I'll use Apache HTTPD for examples here).
A typical configuration of a web server would map the local part of the URI onto a directory on the local file system and just serve up the files there if they matched the local part of the URI.
If the local part resolves to a directory (rather than a file) then it would look for a file in that directory with a name that matched a list (typically including index.html) and serve up that file.
If none of the files on the list existed, then it would generate an HTML document containing links to all the files in the directory.
Since there is no web server involved when the browser is reading the local file system directly, there is no way to map the directory onto an index file, so you would need to explicitly include the filename in the URI (or switch to using a web server).