I have several users on an intranet and all have a mapped drive to server (E:).
All users are on Win7 and use FireFox.
I have used XAMPP on the server to allow users access to MySQL files using PHP.
They currently use windows explorer to open a folder on (E:) so save/modify files (jpgs, docs etc.).
I want to put a link in the html to open this folder for them.
I've spent some time researching this with varying amounts of success and I have found out that this may have security issues such as...
A web application does not have access to the local machine's filesystem
but these are all clients accessing the same server on a local intranet.
I can type...
file:///C:/MyFolder/MySubFolder/
in my browser address bar which opens a page with a directory listing of the files in the sub folder. Not ideal but half way to a solution!
But the script below does not work...
window.open("file:///C:/MyFolder/MySubFolder/");
Can this be done?
you path would be
window.open("http://localhost/MyFolder/MySubFolder/");
or
window.open("http://IP/MyFolder/MySubFolder/");
use absolute path for this
Firefox will work if the link is in its own mangled form using five slashes (file://///C:/MyFolder/MySubFolder/) and the user has disabled the security restriction on file: links in a page served over HTTP.
check this post for more info
Related
I've built an online photo tagging tool that has a low-res mirror of what is on my local laptop. I'd like to find an easy way to display the high-res version of a given image from my local file system.
Currently I have to get the image name from the web tool, paste it into Lightroom's search system and view that way. I'd like to be able to pull up the high res version, either in the browser or another local app, with a single click.
Options I've investigated:
HTML5 File API/FileReader()/fetch()
These cause even more friction than going to Lightroom, as the user has to select files via the OS file selector and the image directory structure is complex.
Configure local web server to host disk-based images
I've looked at hosting the local image directory with a simple web service, but would need to configure HTTPS to prevent cross-zone violations, and that's more client-side config than I'd prefer.
Any solution that would allow me to reference a local file path directly would work, but modern browsers have (rightly) eliminated most direct paths to local file access.
I'm wondering if there is a way to ask an app on the client side to open the file, in the way that browsers will prompt you for permission to open Zoom and join a meeting, or open a link in the client OS app store. If I could find some way to tell Lightroom to open the specific image without having to copy/paste file names, etc.
This question already has answers here:
How to resolve the C:\fakepath?
(13 answers)
Closed 3 months ago.
After selecting a file in Chrome I need to get the full client side path to that file. Currently, the only path I get is something similar to:
C:\fakepath\some_file
All my googling lead me to the following answer: "you can't because of HTML5 security spec. Besides, why would you need to? You can upload it just fine without knowing the path."
This is a perfectly fine and valid answer except that I don't need to upload the file. The website I am managing can have any number of administrator users that configure the website by browsing for and storing paths to a large number of files. All these files are stored on shared network locations that the web server has access to.
The whole point of this is to eliminate upload time, to prevent the need to re-upload the files if the admins decides to change them and to keep the web server storage space to a minimum. Obviously, the web server also processes and manipulates these files. These are all client requirements.
The web server and the shared locations are all on an internal network not connected to the internet. Also, only the users with admin role have access to said locations and to the web pages that allow them to configure these paths. Security wise, this is enough for the client.
We've been using Internet Explorer and by adding the website to the trusted website list it worked just fine but now users are switching to Chrome, the new official and approved company browser. Internet explorer will soon be phased out.
Currently, users are copying and pasting the path into the input field but they want to be able to browse for the file as they did before.
How can I force Chrome to show me the actual file path, is there any equivalent to the trusted websites list from IE or how would you adapt the website to work with these conditions?
For security reasons browsers do not allow this, i.e. JavaScript in browser has no access to the File System.
You could build a chrome extension, see https://developer.chrome.com/docs/extensions/reference/fileSystem/
You can also open chrome with the flag --allow-file-access-from-file, see https://cmatskas.com/interacting-with-local-data-files-using-chrome/
The FileSystem API gives you a sandboxed file system created just for your web app.
I have a ASP.MVC app running in my company's domain. I would like to make links to Word, Excel or even to folders. For example I would like to allow user to access a project folder on public drive or Office document. Files and web app are on different servers, but in same domain.
The problem is that all modern browsers block access to local files. (Chrome throws an error saying "Not allowed to load local resource: file://..."). IE we are currently still using does allow that, but I can't rely on this.
How to tell the browser that it is safe to open those links?
I read about an option to serve .url files to user with link to file/folder. The downside is that I'd fill users temp folders with .url files. And also while I was testing this, I couldn't make changes to .url file after I saved it. Even removing the file doesn't help. It looks like windows stores it somewhere.
Another option was to make an a-tag with href like "data:text/plain;charset=utf-8..." and offer user to download .url file that way. But it was somehow not working for me.
Please help.
Thank you.
I have created a webapp using JSP,Html and Javascript which currently runs on my localhost using apache webserver. I want to display the files and folders and of a directory in local computer. I also want to create a download link or view link of those so that when anyone click on it it will be viewed in new tab or become downloadable as it happens in any ftp server. I know similar type of question has
been asked but none of them worked for me.
To create the download link I used
Download
this does not work as it is not in my webapp path and download attribute also does not work in internet explorer.
I'm not sure why you are exposing your local drive contents on the web but here's an option:
On the page that should display the files, in java code, list all
folders and files then for each file/folder show a link to some page
(for example "navigateLocalDrive" that sends the path of the clicked
file/folder like this:
Download
Now in that jsp, check if the GET variable is a path for a file or a directory,
if its a file, just send it back in the response, if its a
directory, list all files/folders and do the same as in step 1
Please note:
How I encoded the file path in the href in order to work properly.
The Access permissions for the webserver should allow write/read to that path (I'm already doing it on my Tomcat server on local host with the default setup no change needed)
For your reference, here are some helpers for this task:
How to list contents of a server directory using JSP?
Downloading file from JSP/Java
I am not sure if this is possible. In general the access rights are limited to the src and webContent Folder (for your html coding mentioned above for sure) . This is also reasonable, because you do not want to access or change data on your Computer in general, because after local development you want to deploy your web application to a server.
To make a test copy some file to the webContent and you will be able to download it. Within your Java coding you can use some IO package like java.io.File to navigate over folders and files. However keep in mind, that you will get some exceptions like
java.io.FileNotFoundException: C:\WeatherExports\export.txt (Access is denied)
if you want to access files outside the server.
I'm helping a coworker to code an html page that has to display contents (documents) of a local network share.
Html page will not be served by any web server, it will be just a plain html page on file system.
Does anyone know some Javascript libraries that let users browse the share, listing files and folders?
No, it doesn't exist. Same origin policy makes this problematic.
If such a javascript existed it would have to be served by the system and port that the file share was on. Which sounds like it defeats the point.
Now there is an index listing service built into most web servers that can list the contents of a web folder for a browser. There is also a similar capability in the browser for ftp.