-4

I am trying to get the HTML file selector <input type="file"> to browse files that are on my server, instead of local. I know JS is client side, and I tried researching various implementations but no one seems to have something on this. I would prefer an implementation that doesn't require downloading any external application (I already have jQuery and ajax).

edit: I don't know why I'm getting down voted! I'm not trying to get Javascript to list files I feed from the server, I'm trying to explore the servers files and directories like I was physically on it from the "file" api.

A. Abdou
  • 3
  • 2
  • 1
    Probable duplicate of https://stackoverflow.com/questions/7331244/browsing-server-directory-with-javascript – Ullas Hunka Jul 06 '18 at 12:57
  • Possible duplicate of [Browsing Server Directory with javascript](https://stackoverflow.com/questions/7331244/browsing-server-directory-with-javascript) – phuzi Jul 06 '18 at 13:00
  • Use [`Node.js`](https://nodejs.org/en/) for things like that. It lets you execute `JavaScript` as a back-end. – Alex Jul 06 '18 at 13:02
  • Fortunately it's not possible with JavaScript in client. You should list the files with some code in server side. From JS you could call that code with ajax. – Emeeus Jul 06 '18 at 13:03

1 Answers1

0

There is no way to get the HTML file-selector <input type="file"> to browse files that are on your server.

However, you can set up a workaround using a little server-side programming. Create an API route on the server that sends the structure of files that are on your server in response (maybe in the form of a JSON object or an array) and use that to show the file structure to the user.

Aayush Sharma
  • 779
  • 4
  • 20