Access folders and files for creating a html page - javascript

I am new to HTML. I need to create a webpage that reads system path from user and display the statistics about folders and files in a table format. And i want to do the following things
1) Read for folders under path
2) To access sub folders under folder
3) Read the files under a path
4) To get the path of files (to create hyperlink)
For Example, I need to go to the system path given by user in a webpage and read folders in it. For each folders i have to read subfolders and files in it and create a table that displays the name of subfolders under the parent folder and other information about files
So in addition to html what should i learn to do these things. Thanks in advance.

First of all, HTML is used to define and format the presentation of text, images, and other web content, only. And therefore, in order to handle user input and execute server side commands (like listing directory/sub-directories content), you need to write server side code.
Server side languages allow you to create dynamic web content; in your case, code that would:
process the user input,
execute server side command to list system files,
and generate the tables and their content from the return result of the executed command.
php is straightforward easy-to-begin-with language. You can find a basic introduction to php on W3Schools. PHP 5 Tutorial - W3Schools
If you choose to go for php, check the following php function scandir. This php built-in function allow you to list files and directories inside a specified path.

Nodewebkit or Electron both can give you ability to write HTML/CSS/Javascript that will be executed in client machine with access to users filesystem. Check them and see if they fit your scenario.
In short, you will have to compile your HTML/CSS/Javascript as a standalone executable file (various Operating systems are supported) and provide that executable to the client so he/she can run it.

Related

Js - Create a file and save it to a specific folder in the project

I created an excel file via javascript, but when I need to save it the only option is to have the user open the download window and download the file. I, on the other hand, would like the file to simply be stored in a folder in my project, without the user having the option to download the file.
How can I do this? Thank you
You don't provide enough information but seems that you are doing it on the client side (i.e. a browser), which, in principle, does not have access to the file system on your computer/server.
You should try some Back-end approach, like, in your case with JavaScript: Node.js, or maybe anothers like Python or PHP.

Build URL to data file download with link to folder

I have a web application that triggers actions at the server side which result in the generation of data files.
The so generated data files are stored within a folder at drive different from the one where the Web application is.
What I tried so far is to create a shortcut (Windows Server) next to the Index.html, where the shortcut points to the folder at the second drive.
This solution does not appear to work:
If I copy the data file to the same folder where the Index.html file is and enter navigate to the URL httm://127.0.0.1:324324/Data_File.xlsx I get the file downloaded.
If I enter httm://127.0.0.1:324324/MyShortcut/Data_File.xlsx (where MyShortcut points to a folder in drive D) the attempt fails.
How can I achieve this?
The need to access files in the different drive is essential.
You need to configure your server to serve that folder under different location. The only reason you are able to see your app and access that folder is cause server is set up to serve it ATM, not because you are making the right calls from the front or cause the front is asking nicely.
Don't know what Windows server version you are using and IIS version that goes on it, or are you even using IIS (you most probably do) but depending on what you use you need to do something in a lines of this:
IIS7 config
What you probably wanna do is create virtual folder in IIS. Try looking into it, then if you fail ask a question with proper tags according where are you stuck.
I don't see how this is connected to front-end at all so front end tags wont get you far.
EDIT:
Oh, in that case get a second file server running for that folder? This should be the fastest way, use what you can from this list: list

How to access filename from a folder using JavaScript

I am trying to build a simple website with just an index file and a folder full of icons for our internal purpose. I am making this so that anyone in our team can just access the link and download the icons whenever needed without our help. I am trying to read the icons file name from the folder automatically, so every time we update the folder with new ones we don't have to edit the HTML. I know only JavaScript. Please help me.
An alternative could be to produce a filelist of the files via a script or batch file (depending on OS, something like - in psudeo - ls path/to/images > filelist.txt) which redirect the output to a file that ends up in the same root as the index and images.
This file could then be read via fetch() or XMLHttpRequest() and parsed on client side to provide the basis for the links to the updates files.
This would require an extra step in the pipe-line of course, but could easily be automated using a listener for the image directory that triggers the script, part of your project setup and so forth.
This is not possible. In your case Javascript is running in the browser (client-side). It has no access to the servers filesystem. You need a server-side dynamic web-service (php, node.js, ...)

Possible download / upload manager embedded on html page with access to local filesystem

As the title indicates i want to have a certain application get access to the local file system. To describe why i will illustrate my situation:
I am a running a IIS WebApplication with the C# MVC 4 Framework as backend module. The site solely consists of HTML, CSS markup and some JS. The page will be loaded in IE11+ (Edge) only. For the standard procedure of displaying and accessing data from as well as sending data to the server this works quite fine.
On a certain page I want the user to be able to upload a file using a simple file dialog, like the one you can initiate with a simple <input type="file"> tag. I also want to offer the posibility to download files from the server but need to know where files has been saved / will be saved to.
As described on a lot of different websites, just like this one here, the HTML5 File API does a great job but will not be able to return the full qualified filename including the local path directions, same for JS accessing the file object.
As my research confirmed HTML5, JS and also SWF (Flash) will not report detailed information because they are all sandboxed applications or restricted by RFCs. I already unterstood and appreciate the effort to secure my trips to internet.
But in this case do need the paths where a file was upload from and the file has been downloaded to.
So my question is, what is the best way to expose the full path directions for a up- as well as downloaded file to report them back to the server?
Is it possible to embed a SWF object inside HTML which will run inside an Adobe AIR sandbox or is a signed JAVA Applet still the one and only solution to accomblish this security breaking task?
A solution i would also apreciate would be the possiblity to ask the user to get access the file system, like you grant access to the web push service to receive notifications.
Also if there is a possible solution which may suite my circumstances please let me know by adding some simeple examples / revealing some factful links, thanks in advance.

How to find all files in directory? (HTML JavaScript)

How to find all files in directory? I have HTML page in some directory. Using JavaScript I want to get all existing files in some subdirectory ( get all file names or relative links to them, on a local machine)
Unless you have your server setup/defaulted so that you can go to a index-less directory and be presented with a list of files and directories that reside in that directory then that information isn't public.
You might want to try writing a short server-side script to retrieve a list of the files in your directory and make an AJAX call to it?
Javascript which runs at the client machine can't access the local disk file system due to security restrictions. Otherwise one would be able to upload files in a hidden form unaskingly using Javascript.
If you like to access the client's disk file system, then look for the solution in a different corner: an embedded client application which you serve up from your webpage, like an Applet, Webstart, Silverlight or something like that. If you like to access the server's disk file system, then look for the solution in the server side corner using the server side programming language like Java, PHP, etc, whatever your webserver is currently using/supporting.

Categories