Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
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.
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.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have a JavaScript library I would like to distribute to clients for using through script tag on their websites.
My project is not open-source so I cannot use open-source services like jsDelivr.
I was thinking about using Firebase (I hope they have good CDN) hosting where I would upload my script, which will be then directly accessed by other websites. Is this a viable solution or is there other/better service for this use-case?
Firebase Hosting has no access control on deployed files. That means that, like on any public CDN, anyone who knows the URL of the file can access it.
If you don't want to share the code publicly, you should probably not put the file on any CDN. Distributing the code directly to your customers would be the most logical alternative. They would then include the code directly into their build process, instead of pulling it live from the CDN.
But if you want to pull it from the CDN, the best you can do is use an unguessable URL. Typically something very long and random like http://mycdn.com/path/to/file/unguessableFDJIQRE(##(U/index.js. This ensure that random users are unlikely to ever find the file, and only users who know if its existence can get it. That said, here too it remains that anyone who knows the URL of the file can access it.
There are a few strategies here:
Uglify/minimize your JS script. Users will still be able to read it, but it will be hard because all of the variable names will be replaced with not human readable names. That said, it's definitely possible to reverse engineer an uglified script.
Use a JS obfuscator, which will go a step further and rewrite your code to be almost indecipherable.
Set up a static webserver that requires an authentication token to serve up your script. Unless your clients pass a valid auth header, they'll get a 404.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last month.
Improve this question
I'm working on a little side project and wanted to keep it as simple as possible.
So app will have no back end, it will just be a single html page with some local javascript included that can be passed around and run locally.
Given those requirements, I'm looking for a some sort of solution that would let me store and load data like you would a database, in a way the data can be permanently stored in a file. So preferably, being able to use a json file like a NoSQL database.
I've looked at lowdb, alasql, and lokijs, but none of those seem to meet my requirements. They either need a node server to function, or only use local storage or memory to store data.
You can't (except with an ugly workaround).
Such an application would require JavaScript to read/write from disk while running inside a webpage in a browser, and it's not technically possible. This has nothing to do with the file format.
However...
The workaround is to keep all the data in a JSON file, then load it dinamically via JavaScript (for example, with drag and drop). Then when you need to save it... you allow the modified JSON to be downloaded, and once downloaded you'd replace the old JSON with this new one, manually.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am wondering what the best way would be to search or query through a csv that will be in the same directory as an HTML site I am writing. There is a search bar where a user can put the name of someone into, when they click search I'd like there to be an Alert popping up showing some information from that csv matching the name they entered.
I've looked for a few examples in Javascript and php. I'm having trouble wrapping my head around them tho. Does anyone have a fairly simple script that would accomplish what I'm looking for?
Thanks!
You have several options. Most obvious ones are:
1- In JS, you can use built-in CSV parsing function in D3JS:
http://bl.ocks.org/enjalot/1525346
2- In JS, you can use built-in jQuery.get() or jQuery.ajax() function in jQuery:
http://api.jquery.com/jQuery.get/
3- In JS, you can use $http service in Angular:
https://docs.angularjs.org/api/ng/service/$http
4- In Php, you can use fgetcsv() function:
http://php.net/manual/en/function.fgetcsv.php
5- In Php/JS, you can convert your file to JSON and upload it to Backend as a service platform such as Firebase and query it from your app via API calls.
https://firebase.google.com/docs/reference/rest/database/
If having the whole csv on the client side is not an issue, then on page load, I would read the csv through PHP and keep the data in a javascript variable so it essentially becomes a client side search (super fast search).
If you should not have the csv data on the client side, then write a webservice in PHP to read the csv (or, pre read using some other script and store the full csv as an array using php memcached which is in memory store) and then your web service can just search the in-memory array which will also be a little fast than reading the full csv every time your search.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
in the Java IDE I can click an object or function and directly be taken to the file (class) that the implementation lives in. My background has been mostly back-end java coding and front end JSP/JSF type of work and this never been a problem. Now I am working in a front-end environment that is all Javascript/AngularJS that is a ton of small .js files instead of .java files in different folders/packages.
I am trying to understand what's going on because I haven't wrote the code and it would be helpful if I could click on a function, service, provider etc and be taken directly to the .js file it lives in. Is there a IDE that can do that for AngularJS? I assume the only reason like IntelliJ and Eclipse can do that for Java is because each class imports at the top but in AngularJS it's done differently.
Thanks in advance
Webstorm (pure JS)
PhpStorm (php + JS)
IntelliJ IDEA ( java + JS)
All of them are completely customizable by installing plugins
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I want to be able to create a new html file that will be displayed and saved on the server for future use when a new user logs into their account. Can this be done using JavaScript or are there any libraries that I could get that would be able to do this?
This can be done through use of the fs module in node. See https://nodejs.org/api/fs.html.
However, it is very likely that this is not the best solution to the problem your solving. Instead of creating a new html file for every user, you probably want to save user details in a database and have a single html file that can be populated with the data when it's needed.
This is not possible with JavaScript alone unless you use Node.js. Otherwise will need PHP or a similar server-side language.
If you go that route, here is a nice tutorial that may be beneficial to you:
http://tutorialzine.com/2011/05/generating-files-javascript-php/