add print and download protected pdf viewer to web site - javascript

Is there any way to add slide share like PDF viewer to the web site?
Only users can be able to view document... print or download can't be done.I tried several JavaScript plugins for doing that but unable to find one that has no print and downloadable options. And also client can disable JavaScript in browser therefore I think of that suitable server side script.
I also unable to find a server side script (PHP) for this. Please suggest.

Just keep the file outside the web root directory because the web browser follows the local file system privileges and not its own. Put them into a directory with a .htaccess file that blocks all communication.
Ex: Order deny,allow
deny from all
I don't know how much it will gonna help you.

Related

How to load all the file names from a sub folder into my secure web page, using jQuery/JavaScript

I have a sub folder named "images". I want to load all the file names from "images" folder into my html page using jQuery/JavaScript on a secure web site.
How can I do this?
I know how to do this for an unsecured site:
How to load all the images from one of my folder into my web page, using Jquery/Javascript
EDITED:
It's an https page. I can get the contents of a folder in an http page, but I get an '403 - Forbidden: Access is denied.' error for the folder in an https page.
I have access to webserver. I use ASP.NET and tried to set permissions in web.config on the folder for all users.
I want to get the list from the client side.
The client script is executed through the same-origin policy.
I use an ASP.NET web page (but I want to get the files through JavaScript/jQuery).
I might use web services.
Thanks for the details. Im sorry I cant set up an ASP.Net website right now, but I still have a few questions.
Is the client script executed through the same-origin policy or do you need to enable CORS / JSONP ?
https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api
Do you use ASP.Net WebPage, MVC, WebApi, which version or the new ASP.Net Core version?
My recommendation is to build a webservice/API that reads the folder and delivers the list of files:
you can deliver any format you want like a nice JSON, works well with jQuery
you don't need to add/manipulate the web.config which is always better
you will be able to cache the response and avoiding to much disc access. Therefore you need to watch the folder for changes and update the cache
if you want to move/split the folder, moving to a db, anything you might need later, its still gonna work: the url will remain the same
With WebApi this might helps: https://stackoverflow.com/a/25986573/117314

Open local resources with browser in intranet ASP.MVC application

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.

Save Javascript or Replace Javascript File in Chrome Developer Tools

Is there a way to replace a .js file in the website sources with a file on my workstation, or make a modification to a .js file and refresh the website to see the changes?
I am developing client-side JavaScript code against a SharePoint website on a server. I cannot create a local version of the website, so I need to modify the script, save the file to the server, refresh, etc. I do not have direct access to the server, and saving a file in a SP doc library or web part takes a lot of time between edits.
I can make small modifications using the dev tools while breaking on certain lines and applying snippets, but I am hoping for a better way.
Thanks!
If you have access the server that's hosting the file you should be able to replace or modify the JS file. Alternately you can use local hosting tools to test your file and then upload it to the server once you've confirmed it's working.
If you explain what you level of access to your host is we can offer better suggestions.

How to show browse for FOLDER window(not browse for file)using just JSP and javascript?

I need a code for how to browse for folder (not file) using JSP and Javascript.
I looked for the JAVA code for browse for folder using JFileChooser library but I want the default window to be opened (which opens in browse for file).
I'm developing a webapp which will scan the folder based on the path and will generate the output.
Thanks in advance.
1.I need a code for how to browse for folder (not file) using JSP and Javascript.
Javascript does not have access to the file-system due to security reasons, as this answer says and also this answer.
So you would have to use flash or java applet as suggested in this answer or else you would have to wait till the time HTML5 File API matures :-)
But, if your requirement is that your a User (may be with administrator rights in the application) logins to the web-application through a web-browser and wants to scan (view the contents of) the particular folder on the server side (where the web-app is deployed and not the file system on his own machine) then you can use the suggestion given in this answer, just to elaborate on this:
Have a <form> which will have a text-box (to take the folder name or full-path) in the JSP, on submit of this form a request will be sent to the server.
The response would be list of files (List<String>) in that particular folder passed through the request.
you can also submit the request through ajax in which case you would return a JSONArray as suggested.
Now on the Server it would be normal Java File API stuff to fetch all the files in the folder you get from the request.
Sorry to say this but I don't think you would get a ready-made code to do what you want and that is not how things work on SO.
2.I looked for the JAVA code for browse for folder using JFileChooser library
You said you are building a web-app right? JFileChooser is a Swing component and as far as I know cannot be used in JSP to achieve what you desire.
3.I'm developing a webapp which will scan the folder based on the path and will generate the output.
The steps are explained in point (1).
Hope this helps and gives relevant hint and direction to go forward.

How to access and browse a network share via browser using javascript?

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.

Categories

Resources