Search code examples
phpfilesaveserver-side

Access a file on a HTTP server via PHP with any application


In an attempt to add features to an online platform for file sharing, I would like to offer a seamless Integration of the platform content itself with other applications. This Integration should allow registered users to open and edit an uploaded file on the server. In the end the user should be able to open a link, e.g. API.php?File=/Overview.odt, in an editing software of their choice and be prompted the required document.

However, when the user saves the document, it will be saved as a temporary document on their computer (disk). Is there any way to directly access the file not only to open it, but also for saving?

I already looked at the FileWriter specification but wasn't really happy about the browser support...

Thank you for your answers.


Solution

  • You can submit your updated document through a GET or POST HTTP form, with an action field linking to a PHP script in charge of processing your file (if any processing is needed) and storing it somewhere accessible.

    You could also rely on the WebDAV extension of HTTP, but those are rarely activated by default on web servers.

    Anyway, you should be aware that when designing such features, the risk of introducing vulnerabilities on your website is pretty high.

    Also, it is not clear to me how you can expect any possible application to use your interface automatically, unless you set up some kind of Dropbox-like daemon watching a synchronized folder on your local machine.