Host files locally with predictable/controllable URL on Synology NAS - html

I am trying to find the best way to host a bunch of pdfs(and other files potentially) on my synology DS1821+ that can be accessed by a URL so employees can access them by scanning a QR code. The files should be available to any device connected to our WiFi.
I was able to achieve this quite easily using WordPress and simply uploading the files to the "Media Library" And converting the URL to QR code using my web browser.
Here is an example of one of the URLs provided:
http://10-0-1-128.synologynas.direct.quickconnect.to/wordpress/wp-content/uploads/2022/10/F09042-fix.pdf
this also works:
http://10.0.1.128/wordpress/wp-content/uploads/2022/10/F09042-fix.pdf
However, since we would be printing potentially thousands of QR codes to be used around the factory for years to come I need the URL to be something I can control manually, without stuff like "2022" in it so that if someday we switch to different software/hardware we can replicate the same structure so as not to need to reprint and redistribute thousands of QR codes.
I see the application "File Station" on my NAS and this is close to what I want but not quite. There I can right click a file -> share ->QR code and it returns something like this:
http://gofile.me/73nWA/C8AYNuBpv
Pretty cool, but again the URL is not something I can control, and also it uses some advanced voodoo to make the link work anywhere on the internet and these need to only work on our local network.
Any thoughts on the simplest way to achieve wat I'm looking for?
-Thanks
Edit -
I see now that I can add a folder to the "web" directory using File Station, and then add files to that folder and access them in my web browser by going to:
/folder/filename.pdf - (although if I right click it and say open in new tab it access it through a long and convoluted url???)
which is basically what I wanted
however, I would like to be able to also go to:
/folder
and see a selectable list of all the files as well
I know I can create I link by adding something like
<a href="file.pdf" etc etc etc
to the .html file, but I'm working with about potentially thousands of files.
Is there a way to just generate one for every file in the folder.
as I'm sure you can tell I'm a noob at this.

Figured it out.
As long as you have some web server SW up and running you should be able to acces files placed in the /web folder of the "file station." for example if there is a pdf in the web folder named document.pdf you can access it by going to /document.pdf in your browser on local network.
If there is a folder name named pdf with files in it in the /web folder
you can add index.php to that folder with the following code in it to see a list of links to the files in it in your web browser.
<?php
$dir = "/volume1/web/pdf";
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
echo " <a href=./$file>$file</a><br>";
}
closedir($dh);
}
}
?>

Related

Files not showing in htdocs

When creating a new database through PHPMyAdmin and trying to access localhost/newdatabase, I get this message:
"Object not found! The requested URL was not found on this server. If
you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404 localhost Apache/2.4.34 (Win32) OpenSSL/1.1.0i PHP/7.2.9"
The file doesn't show in xampp/htdocs either, only in xampp/mysql/data.
If i create files directly in htdocs, they work perfectly on localhost/.
Why has the file not been created in htdocs?
The content of the htdocs folder are files that can be interpreted by the browser such as HTML5, CSS, JS, etc... in order to show a webpage along with it's funcionality to whoever accesses it. A database in the other hand can't directly be opened by a browser, but rather accessed within the server by a backend language like PHP, in order to get the information that can be stored in it through tables. You seem to be new to web programming, so I'd recommend to quickly google some beginner tutorials that can help you to understand the most important concepts. To take on from your kind of confusion, I'd point you to expand your knowledge on these concepts:
HTML5
CSS
PHP
MySQL
Once you get the grasp of them and identify each by their core funcionality, you'll be good on your way to make webpages. Later on you'll find yourself with demands like making your webpage look nice and clear, and also to make it load fast, but there's time for everything and the concepts I pointed are the best start for you.
if you wanna open your database URL = http://localhost/phpmyadmin/
File directory ~ xampp/htdocs for source code such as extension file .php .html .js or other.
if you wanna load localhost a URL is http://localhost:80 (auto find index file to first load)
Sample given as image folder for my code. Hope that can help you to understand xampp

HTML - How to run a file from the user pc?

I'm creating a little project in HTML and there's something that I would like to do.
Imagine that my HTML page is hosted, and you can download there some .ppt and .exe files and place to a specific folder.
Now, that's the problem. Considering that the files are in the right folder, I would like to run these files when the user select their respective options at the HTML page.
Does anyone know how to do it? Thanks :)
This isn't directly possible, for security reasons.
If you control that application or can install something on the user's system, you can associate a file type or URI handler with the application you wish to launch.

Get .html filename of a website with Firebug

How do I find the filename of an website I am inspecting with Firebug? As example when I look on http://example.org/ I can view inspect the Element, I see the whole html structure but I didn`t find the filename. I am searching for index.html or something in that way. Maybe this is an analog question, but I am not sure, because he/she is working with php. LINK
I know there are some solutions with Dreamweaver or other tools but I am searching for an easy way to figure that out with Firebug or an free Browser Add-On. I Hope you have a solution for that.
The URL you entered is the one that usually returns the main HTML contents. Though on most pages nowadays the HTML is altered using JavaScript. Also, pages are very often dynamically generated on the server.
So, in most cases there is no static .html file.
For what it's worth, you can see all network requests and their responses within Firebug's Net panel.
Note that the URL path doesn't necessarily reflect a file path on the server's file system. It is depending on the server configuration, where a specific URL maps to in the file system. The simplest example is the index file that is automatically called when a domain is accessed. In the case of http://example.org the server automatically loads a file index.html in the file system, for example.
So, in order to get the file name on the file system, you need to either check the server configuration or the related access logs.

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.

How can I find my working directory?

You'll have to bear with my slightly on this, but please ask if I have left out any pertinent information. I have just taken over a project to create a dashboard for my team. This dashboard has been made using a niche third-party tool that nobody here will have used before. The third party tool auto-generates some code to display "markers" on a webpage. "Markers" being some proprietary code to query a database/apply custom styling etc.
I am trying to display a webpage within the page that has been generated, and I’d like to point this to a local webpage (ie on my C drive). If I pass it an absolute path, then this results in a warning in IE9 as I am mixing data sources - a https website pointing to a http web page. It will display after ignoring the warning, but my userbase is not comfortable enough with computers to ask them to do this.
I believe if I pass it a relative path then it should work, but I can’t find out what directory to base this path off and it doesn’t appear to be anywhere obvious. So, in my current page I have an image with the web address of : https://website:8443/websitereport/images/buttons/locked.gif. What I need to know is where the “websitereport/images” folder is stored so that I can put my webpage in there to give the webpage a relative path. The HTML for this image is :
<img id="dvp_locationbar_lock" class="dvp_imagebutton" style="" dvp_title="ui.tip.lock-page" dvp_image="locationBarPageUnlockedImage" src="/websitereport/images/buttons/unlocked.gif" title="Lock this page">
What are my options for discovering where this folder is stored locally? I am running Apache Tomcat 7.0. It is not displaying if I use the path based off
C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\work\Catalina\websitereport
of
\websitereport\page.html
And I cannot find it anywhere obvious in the Apache folder. I have tried :
Searching - no results.
Using PHP to print the current working directory - cannot find out
where to edit the webpage.
Looking at images/information on the existing webpage. They all point
to folders I cannot find.
Inspecting with firebug.
In short, you can't rely on the files being on disk at all - they might be just contained in a *.war file, containing the whole application. Or they might be generated on-the-fly, despite the name sounding like an actual file.
Also, you should not arbitrarily write within a directory even if you find it (my closest guess would be tomcat's webapps/websitereport/ directory if it exists) because nobody will know that something changed during the time since last deployment. So, on the next update of the application, you'll end up overwriting all of your changes again. You typically change the underlying application and redeploy.
You might also find a few references in tomcat's conf/localhost/ directory or even in conf/server.xml, but it all depends on how your server was administered