Using JS to Read a Web Server Directory: Possible?

  • Java
  • Thread starter ComputerGeek
  • Start date
  • Tags
    Server Web
In summary, you can use JS to read a directory on the web server and use that information on the web page. However, you will need to write functions to extract data and create a dom structure.
  • #1
ComputerGeek
383
0
Is there any way that I can use JS to read a directory on the web server and use that information on the web page?

I originally did this in PHP, but the server I built the site for has no PHP installed and the admin does not want to install it. On top of this, there is no CGI or ASP functionality set up.

so, I figure, rather than generating static pages on my computer when new data is added to the server and then uploading the page, I could perhaps use Javascript. I have not used JS much because I do not think it does much for you, especially when you use server side scripting (form validation is the only place I would normally use it).

any ideas?
 
Technology news on Phys.org
  • #2
I guess you could embedded everything you need in a .js file, but that would be a pain. You'll need to write functions to extract data and create a dom structure.
 
  • #3
dduardo said:
I guess you could embedded everything you need in a .js file, but that would be a pain. You'll need to write functions to extract data and create a dom structure.

perhaps I will just use an <object> tag to use the php output from a server that runs PHP now.

any way I can host the files on the main server and have the php read those files? I tried by just adding the domain to the front of the directory (http://blah.blah.com/directory/ ) but that did not work.
 
Last edited by a moderator:
  • #4
Wait, so now you have server with php? Why don't you use that server?

Huh? You can't just magically create subdomains. There is a little more work involved.
 
  • #5
dduardo said:
Wait, so now you have server with php? Why don't you use that server?

Huh? You can't just magically create subdomains. There is a little more work involved.


no no.

The server that I have space on does not have any Server side scripting. I have a server with a personal account on it that has PHP and CGI set up, but not the ability to host the site I am making due to the situation. The files being manipulated by the php script are larger and I do not want to take up the space on my personal account with them. so I figure I can host the php script on my personal account and have the files on the other server.
 

FAQ: Using JS to Read a Web Server Directory: Possible?

1. How can I use JavaScript to read a web server directory?

JavaScript has a built-in object called XMLHttpRequest that allows you to make HTTP requests to a server. You can use this object to send a request to the server and retrieve a list of files and folders in the directory.

2. Is it possible to read a web server directory using only front-end JavaScript?

No, it is not possible to read a web server directory using only front-end JavaScript. This is because accessing server files and directories requires server-side scripting, such as PHP or Node.js.

3. Can I use JavaScript to display the contents of a web server directory on a webpage?

Yes, you can use JavaScript to display the contents of a web server directory on a webpage. You can retrieve the list of files and folders using XMLHttpRequest and then use JavaScript to manipulate the data and display it on the webpage.

4. Are there any security concerns when using JavaScript to read a web server directory?

Yes, there are security concerns when using JavaScript to read a web server directory. If the server is not properly configured, it may allow access to sensitive files and directories. It is important to use proper security measures, such as authentication and authorization, to prevent unauthorized access.

5. Can I use JavaScript to read a web server directory on any type of server?

Yes, you can use JavaScript to read a web server directory on any type of server as long as the server allows HTTP requests and has a properly configured file system. However, the specific implementation may vary depending on the server and its capabilities.

Similar threads

Replies
15
Views
2K
Replies
12
Views
9K
Replies
50
Views
5K
Replies
13
Views
2K
Replies
13
Views
2K
Replies
22
Views
1K
Replies
1
Views
2K
Back
Top