Can anyone tell me why this only works when I upload it and not when I open it in a browser on my local system.
https://teac.lenguax.com/tests/ADP-Driver/ADP-001/testBed.html
The only difference I do see is that, when it is uploaded, I get https:// and when it is on my local system I get file:/// - is there any way I can make this work on my local system without having a local webserver?
Any help would be greatly appreciated.
Cheers,
Tyrone
...when it is on my local system I get file:/// - is there any way I can make this work on my local system without having a local webserver?
Security around the file: scheme is browser-specific. Chrome is fairly restrictive, whereas Firefox is more permissive. So you might try Firefox.
But: Lots of things are slightly different and off when you use content from the file: scheme rather than http:/https:. I strongly recommend using a local web server when doing browser programming. Any good IDE will have one built in, and there are many Node modules (for instance) that will run your project in a local server as well. (And installing a local server isn't all that difficult.)
Related
I am developing a website with frontend react and backend as django where users can generate names of files in a particular format. Now this files will be in their local system or their local servers we can say. I need to rename the file and move that to a source folder. Is that possible using a website? I have heard this is possible but now sure how. Anybody knows how this can be done?
Browsers accessing the local files system is considered as a security threat!
Imagine websites having the freedom to access all your files and images!
however for certain use-cases, this can be enabled on the browser itself, to enable websites from accessing file system.
however it is supported by google chrome only (as far as i know) you can use the FileSystem.API you can check this here Can i Use: FileSystem
I built a CRM for a client of mine, and now they've requested an interesting feature:
For each customer record, they have a matching directory of files on their local computer. They want the ability to open that folder in Windows Explorer directly from within the web app (the app doesn't need access to the directory/files; it just has to launch Windows Explorer so that the user can interact with their files).
This is obviously not possible with regular JavaScript running in the browser (thankfully). I thought there might be some way to accomplish this by building a Chrome extension for this purpose, but it seems Chrome extensions/apps can only access a sandboxed filesystem, which doesn't serve my needs at all. Building an NPAPI plugin in out of the question since Chrome is discontinuing support for NPAPI.
File URIs don't solve this problem either. Their display is ugly, there's no drag-and-drop, no big icons/thumbnails, no sorting etc. They want the full capability of the Windows Explorer.
The only viable option I thought of is to create a local node.js server, make a localhost CORS request to that server, and then run an exec command from node.
Any better idea?
One possibility is to register a custom URI protocol handler with the user's operating system, and then your web page can contain links using your custom protocol, such as openfolder://c/path/to/folder This sort of customization is probably most commonly seen in practice with itunes:// links.
A quick Google search led me to this decent looking tutorial: https://support.shotgunsoftware.com/hc/en-us/articles/200213756-How-to-launch-external-applications-using-custom-protocols-rock-instead-of-http-
The downside is that the user will have to run a small installer of some sort in order to set the correct registry entries (or whatever the non-Windows equivalent is for other OSes) and to drop a small script on disk. That would be much lighter-weight than running a node.js server like you proposed, though.
The linked tutorial uses a Python script, but even that is probably overkill for your needs. A batch file would likely suffice.
EDIT: One additional note, please be aware of the security implications of implementing a custom handler like this. Any webpage in any browser can potentially take advantage of your custom protocol, and an attacker would be able to pass arbitrary data to your script. You should take steps to ensure that the script will not accidentally execute arbitrary commands that may be injected by a malicious web page, and that it will only open a folder and nothing else.
That would require each customer to run a node.js server, which seems unrealistic in your case.
You could use File URIs.
Browsers will refuse to open them by default. However, as suggested in this answer, you could ask your customers to install LocalLinks.
I understand that javascript running in the browser would not be allowed to access a local file system directly, it make sense and I am not looking for a way to violate that.
However are there any safe and kosher ways to grab files from the local system for the browser to use? Would these methods be platform specific? Would I be limited it what kinds of files and would access have to be granted on a per file basis?
What I am thinking about is when you upload photos, it will open a system level dialog and then eventually present that file to the browser for the browser to send to a remote server via http. Would it then be possible to pass a file in to the browers local memory/ give the browser permission to read it as it were to be upload but instead of uploading it somehow pass over to java script and allow it to manipulate it client side much in the way you can manipulate files with server side javascript?
The reason I am asking is because I have recently become interested in browser-based file manipulation programs, their feasibility and what could be done with them in a Chrome OS type environment. Just out of curiosity then any idea of it being practical any time soon.
edit: attempted to clarify and make my question more direct.
Use the File API (MDN has a tutorial) but be aware that it is a new specification and has limited browser support.
It allows files selected in an <input type="file"> to be accessed with client side JS.
Ok so I'm lost here, frustrated and pulling my hair and out. Plus probably about to be fired or take a pay cut.
I moved Files from a development server to my local machine. The files are consistent (used diff tool), all the dependencies are there. It works for the most part. The problem is that the some of the javascript (not all) is just not working. We're using jquery and a lot of plugins for it. I've checked with the web developer plugin in firefox and all the js files are loading. I cleared the cache in both firefox and chrome multiple times to no avail. The development server is a windows server running wamp. My local machine is running ubuntu. Somebody tell me what I missed.
Download firebug as a Firefox extension and view the http request and responses.
Easiest may be from within the 'net' tab to determine if your script is making a request.
Very likely that it is a source domain issue. There are no work-around for this issue. The ajax request and the source data must be on the same domain.
It may have something to do with JavaScript's security limitations. (In certain circumstances) You can only operate on URLs or pages from the current domain, which most likely changed when you moved the files off the other server. More here.
Are you running the files via a webserver, or just opening the files directly? If it's the latter, you'll want to set up a server on your local machine for local testing, and serve the files using it. Otherwise, you'll very likely run into the domain restrictions others have mentioned above.
You may need to host the site using a local server. VS IDE has an add-on called live server. You need to set up a workspace in order for it to work. The port used on my machine was 5500.
You need to make sure any dependencies for javascript are running on your server or the javascript will not be executed. These dependencies are listed in the json file.
ex. If you require express, you need to be running node or the javascript won't execute in your web browser.
In the terminal:
node app.js
Any dependencies that are not installed and running on the server will not execute.
Are you accessing the html web pages through the webserver and not simply double clicking the file to open it?
Also if you have WebDeveloper toolbar installed the click "Disable", "Disable Javascript" and make sure "All Javascript" isn't ticked.
As a followup on this answer:
Specified javascript does work in case of a local website, but fails in case of a remote site. The firefox extension locallink helps in case of links, but is useless in case of the javascript solution provided by the linked answer. Please provide possible workarounds for redirecting to local files (unc) in firefox.
The only way I can think to do this would involve a signed, Java applet running on your page. Essentially what you'd do is provide the file to the applet and have it open up a new browser window with the file's URL. Since the applet is trusted by the local system it should have access to the local hard drive and should be able to start up a new application.
Note: I've not tried this, I'm just speculating on how I would do it. I have used a signed, Java applet to get at some local networking parameters for use in a Wake on LAN application so I know that signed applets are allowed to interact with the system in ways that browsers can't.