Apache PDF digital signatures - javascript

I have a website with a directory listing of all the pdf files which I have uploaded via ftp. By clicking any of the file names, the pdf document will show up in your web browser. Is it possible for outside parties to digitally signed the document in the web browser and save it back into the server with a appended "signed" on the file name.
My main problem is:
saving the signed document back into the server via the web browser
change the file name when the document is saved

It will depend on your permissions but if the user downloads it via http (you have directory listing enabled on your website) they should not be able to save it back to the site unless you allow it to be uploaded.

I would suggest reading the PHP upload tutorial.
You might consider WebDAV, but I would not recommend it.

Related

How can I read a local file with a fixed path in Javascript? I only have the location of the file as a string. NO HTML forms allowed

I am creating a web app where I already know the location of a file that needs to be uploaded. Note that all I have is the path (example: Users/username/Downloads or Users/username/Documents) or something like that. How can I get Javascript to read that file as a File object or as a binary string so that I can POST it to a server.
Additionally, this file is not a simple file like a JSON or a txt file. This file would usually be a Microsoft Word file.
Due to security reasons, JavaScript executed from web apps have very limited access to the file system.
The best you can do is have the user select a file via a file input.
If having the web app user install a browser extension is acceptable, a browser extension may have more access to the user's file system. Here is an example extension that accesses a user's file system more directly: https://github.com/buggyj/savetiddlers
I think you can't to read the any files from the front-end by javascript, It is not allowed to do so. But you can get the file path from front-end and then pass it to the app framwork or back-end to processing. Beacuse the app's framework or back-end has the ability to access system files. Whereafter, you can POST to the contents of the file to the web server.

Open Files in Browser instead of downloading (including files like .doc, .xls etc)

I am using Java Rest APIs to upload files in my project. Based on the configuration my files either goes into s3 bucket, google drive, one drive or even in local file system (in the same machine where my application is running). During download again I am making an ajax call which returns the file in response with Content Disposition header attachment; and browser downloads the file irrespective of its format. I want an option to view these files in the browser instead of downloading it directly. How can I do that ? (Especially formats like doc,xls etc)
As far as I know, there are no client-side libraries exist that can open .doc, .docs, .xls in browser. There is a way to render render your files using browser is to use Google Documents' Viewer or Microsoft Office 365 viewer via an <iframe>. Using this inside an <iframe> you can open your file in side your browser but can not edit.
Google Documents' Viewer inside <iframe>
<iframe src="http://docs.google.com/gview?url=http://example.com/path/to/your/document.doc&embedded=true"></iframe>
Google Documents' Viewer clickable link <a>
Open your doc file
Microsoft Office 365 viewer <iframe>
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http://example.com/path/to/your/document.doc' width='1366px' height='623px' frameborder='0'></iframe>
Browsers don't have any built-in way to view Word docs so unless the user has configured their browser to open it with some plugin (which 99% of the world hasn't done), the browser will prompt them to download the file.
However, if you only need to display the Word Document, but don't need to edit it, you can use Google Documents' Viewer via an to display a remotely hosted .doc/.docx.
<iframe src="http://docs.google.com/gview?url=http://url-of-the-file&embedded=true"></iframe>
you can generate temporary URL for your s3 documents by keeping them private.
if you are interested in giving users privilege to edit them online then you can go with any tool like onlyoffice

Browser display of host filesystem

I am working on an embedded project that implements a filesystem on a flash card. An embedded web server provides user interface and control through a web browser. One of the required functions is the ability to upload/download files to/from the embedded filesystem and the local (browser) filesystem. The upload function will be easy - using an HTML input type of "file" I can create a file selection box in the browser that displays a popup window and allows browse/selection of the local filesystem file to upload. The extension of the file will tell me where to put it in the embedded filesystem. The problem I'm facing is download - HTML5 provides a download attribute that pops up a window that shows me where to store it on the local filesystem. My problem is how to display the remote embedded filesystem directory so I can select which file to download. I can provide any information needed about that directory via the embedded web server, I just don't know how to (easily) create a nice browser popup window that will allow me to display/browse the remote filesystem. Is there any browser popup window that functions for the host side like there is for the client side?

How to view local files in web browser by displaying and creating a link to local files stored in your computer in your webApp?

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.

how to open csv file in IE in by javascript

In my asp page, I have to open a csv file in IE by java script. The code which I am using is as below:
csvWindow = window.open("/com/csv/"+csvFileName, "datacsv", "toolbar=yes,location=no,directories=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=790,height=450,screenX=50,screenY=25,left=50,top=25");
Code is running in IIS server.
When I run this code and open csv file it gives below message
Microsoft Office Excel cannot access the file
"http://192.168.3.228:107/com/csv/CSV_file_1345728.csv". There are several possible reasons:
The file name or path does not exist
the file is being used by another program
the workbook you are trying yo save has the same name as a currently open workbook.
But file is being created.So path is correct and i think that file is also not used by another program
Please help me what should I do
The problem is that when Excel is opened it will attempt to fetch the CSV file itself, this a change in behaviour in office apps since 2007. However since Excel runs in a different process it will not send any cookies that would have been generated during the logon. When the website receives the request it will respond with a 401 status.
There are no easy solutions that I know of with entirely satisfactory results. Here are a number of solutions but all have drawbacks.
Make the authentication cookie persistent, this will allow Offices apps to pick up and send the cookie. The down side being the user remains persistently logged even after a client machine reboot (much like how Stackoverflow appears to work).
Use a standard HTTP authentication protocol like "Basic" or "Negotiate". The down side is that this will cause Excel to display a logon box and the user has to logon again. One exception to this drawback is using "Negotiate" or "NTLM" against an IIS box where the site is registered as part of the IE's Intranet Zone, in which case the HTTP stack used by excel will attempt to use the current user credentials.
Have a server side script that can run anonymously send the csv file and include in the URL some unique ID (such as GUID) which is a one off grant of access. Much more complex to set up.
If you want to open the file with MS Excel, you could try not to serve the file directly, but write an ASP page with Content-Type=application/force-download, the real file name ending with .css and the actual file content. In this case, MSIE will first download the file to the local disk cache and then will feed it to MS Excel.
If you just want to show the CSV text in the browser window, maybe the best is to change its extension or to make some proxy page with Content-Type=text/plain and no mention of CSV at all. The association CSV/Excel seems to be hardcoded in MSIE.

Categories

Resources