Opening a word document on clients PC, through a PHP application - php

I am developing a web application in PHP as a replacement of Microsoft Access based application for a company.
In old access application in their database they were storing a link to a word document, which further links to other documents. Now in access form they are showing that link, when click on that link they can open the word document from a common folder in a network PC and make any changes the that file (pretty easy for user).
Is there any way to do the same through the web-based application?
What if I just move the common folder in my www directory?
In that case they can open the file easily, but if they have to make any change they have to download the file on their PC, and the changes will be done to their local file not in the file that is on server. So they need to move file to server back or ask network admin for moving the file back to the server
What if I keep common folder in a network PC it self and try to access it form there?
Just by clicking I can’t open a file form client’s or any other network PC. For this when click on the link I have to open & read file through PHP on web server. Using any document to PDF converter, I have to convert the file format and then open it in browser. Here the problem are,
Still I can’t make changes in file and
I have to fix about the format that I might need to convert in PDF.
I am not sure how the other documents that are linked to the main document will work.

There's two ways of doing this: (a) let the user download it from your web application, either statically (stored on the web server) or dynamically (processed in PHP or even built in real-time).
Or, (b) use a file link to a known location on the user's disk, such as file://C:/mydoc.doc.
Addendum - if you want to write to the file in your web app, but also have the user open the same copy, use (b) rather than (a). This presumes that the location of the file is available through a local or network path.

Related

Prevent download of PDF file from site

I have files stored in the server with the Plesk panel, currently, any person with the link of my site can access the file and download it.
Is there any way to prevent the download for all the users?
The general approach is to create a folder that is not in the root folder of the web site. In other words, you don't allow nor have valid URL's to a folder as a result. This does mean then you have to build some type of web page that can say list out some files and a button to click to download such files.
In other words, no valid url's exist. This tends to suggest that you have some type of grid or display of files. often even a database table to drive such a display is used.
When the user clicks on say a button on that grid row, then code behind can fetch the file, and "stream" it down to the user. The end result is thus no valid url's or resolvable path to the files exists.
Also, from IIS, turn off directory browsing. and thus again no valid URL's to the files exists.
The other approach? You can build a custom http handler. This approach is quite common. That way, any url that ends in .pdf will be trapped, and thus not allowed. As noted, this again means you have to provide a "list" of files, and a button to download - and again you can then stream the file from the server.
So there is quite a few ways, but ultimate, I as a general rule don't allow files to be downloaded or even accessed by URL's. I always provide some kind of web page, and a list of choices for the user. The code behind is what actually fetches the file, and then streams it down to the browser.
So, you can
Search for how to build a custom http handler for pdf files in asp.net
Search for how to stream a file to users in asp.net
how to turn off directory browsing in IIS.
There are a truckload of options here - in fact too many to really post and explain in Stack Overflow answer.

Integrating MS Office with PHP & SQLServer Filetables

I have implemented a Document Management System (Web Application) in PHP which stores all documents on SQL server in Filetable. The Software works fine with Downloading the document, modifying it and uploading back to the server.
My Question :
1: When the file is downloaded the browser handles it as an attachment and could be opened in MS-Word by the user. Is it possible to open the document in particular application for e.g in MS-Word? Make changes to the document and while saving the document it saves/uploads directly to the SQL server. So that the user doesn't have to upload it back from my web application.
I would appreciate any leads to the solution.
Thanks in Advance.
You could setup webdav endpoints which interacts with your file database.
See also this question:
Open remote document and save back to remote server
There is a feature in SQL with name FileTables this allow for client application (ex: ms word) to open the file directly from Database using network share folder. This also allow to store directly to database without any programming.
I also come up with this question and see this as an options. But I still didn't know if this feature can be combined with WebDAV.
ref: https://learn.microsoft.com/en-us/sql/relational-databases/blob/compare-options-for-storing-blobs-sql-server?redirectedfrom=MSDN&view=sql-server-ver15

Can a web application open a pdf file that exists on the client side

I have an ASP page, in which the user chooses a value (e.g drawingId) from a list box, and according to this value, ASP builds/calculates a file path, e.g. c:\drawings\file1.pdf, in order to show this pdf file to the user. This path refers to the client's computer, where these pdf files are stored. The server queries the database and knows only the association between the drawingId and the path at the client's computer.
How can I open this pdf file?
I've read similar questions, like How can my web application written in Java open a file on the client side? or Can javascript access a filesystem?, but I haven't understood how to proceed.
I would like this to work with all browsers and also implement this functionality in a PHP site.
Use file:///
e.g. file:///c:/filename.pdf
Well I guess after user selects option from a list box, you could construct the path and redirect user to that path which should open the pdf file
eg.
file:///C:/foldername/filename.pdf
it not possible to open client side file from server side code as it running at server side, also due to some security reason browser does not allow to browse client location
refer link Open local folder from link

Get directory listing from any URL

As far as I have read, PHP can only get the file listing from local server on which script is running.
What I need is the list of files in a directory on an external URL, which is not FTP but an HTTP URL, such as www.google.com. Is this possible in PHP?
Here is example of what I want (but FDM is C++ app)!
You can only see this if the webserver allows it
This is not possible in any language.
If a remote server does not want to list directory contents (i.e. if it's configured not to), no external script can generate one; that would be insecure.
Free download manager does not show the files in the folder, but all the links found on the web page. You can get a web page with curl, and grab all links from it (using regular expressions), then download the linked pages - that's how web-spiders are build. But you cannot get list of the files that are on the server, only the one that are linked in a publicly available web-page.
You can see server files only if the server allows that option, alternative you have to install your own script that will do that work for you indepent of the server settings. That also means that you have to have access on the server that you like to list the files.

Download file using FTP and PHP

I would like to start a upload and download website for huge files (up to 1gb). I thought that it would be better to download the files using FTP (with PHP), because this protocol is especially used for these types of transfers.
The cliënt gets an email, including a download link to download the file (like yousendit.com). When they click on the link a download box appears. My problem is that I don't know how to show a download box using ftp and php. I have read that it isn't possible to immediately download a file by PHP, using FTP. Is this correct?
Do I have to create a temporary files on the server to let the client download the file? If yes, is this also a good solution for huge files?
What do you advice me to give the clients the possibility to download these huge files?
Thanks for your reply!
You can generate unique address based on session_id (create this folder on runtime and move huge file there) and redirect user to this link
For example, you have file huge.tgz
1. Send you client link http://***/user/john/file/huge.tgz
2. Ask user for auth in this page if they lost session
3. get session id
4. create on your server folder with name equals session id and move huge.tgz here
5. redirect user to unique ftp link ftp://***/17oe5kf8iYmpt66bjs89hcuo83/huge.tgz
You should disallow list files and directories on ftp server
Can't you send them an FTP link ? Why do you need PHP?
ftp://ftp12.freebsd.org/pub/FreeBSD/ls-lR.gz
You probably want to use PHP to handle everything but the file transfer. Once you have done all the checks you want you can redirect the browser to the file specifying the protocol as ftp. though you won't be able to have a progression bar in your site, the browser/ftp app will probably display one.

Categories