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.
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.
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 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
HTML5 is great and I can replace my existing desktop application with it, but just a little security restriction prevents me to complete my job. I plan to create a simple desktop application completely with HTML5 so it can run on any mobile and desktop devices that support HTML-5.
I know about the browser security on local file and the reason behind it, but I don’t know why I couldn’t find a way to grant read-only access to a folder as sandbox. My application does not need to write a file or even does not need to read a file outside of It main html folder. It needs to read the local file just in same folder same as it do on domain.
So please let me know:
Can run browser with specific command to force it grant access to local file that exists in same folder of HTML? It should not disable all local security restriction just grant HTML access to file in same folder or subfolder.
Is it cross platform method to map a local folder as local host that work on mobile platforms?
Is there any manifest file exists to put in folder to grant read access in same HTML folder?
Is there any way to grant read-only access to a folder as sandbox?
Note: I don't want use third party solution such as XULRunner, Mozilla Prism, Adobe Air or any other third party, I need HTML-5 solution to be cross platform if there is any.
Any idea is welcome.
If you need that file so much, why not just load it dynamically inside a JS script as a json object.
So, in other words, put the contents of the file into a js script, and strucutre the file contents into JSON format, then load that script on load or when you require it.
Alternately if you need file IO use localstorage.
according to this site, launching chrome from the cmd with the parameter --allow-file-access-from-files will disable this security feature
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.