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

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.

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.

Related

Can A Webserver Force the Client's Computer to Open a Filetype with any Given Application

I'm pretty sure I already know the answer to this, as being able to force the client's computer to open a file with the "Webserver chosen application" would be a huge security risk, but I'm going to ask it anyways.
Can you force an end user's computer to open a file using a certain program? For example, can I use my server to tell a client computer "You need to open *.reg files with Media Player"?
Some background is that we have this website that recently got revamped; it moved from Rails to Drupal, and now the client is saying that when she downloads a .reg file on her website, it tries to open it in Windows Media Player. She says that this didn't happen until we switched websites, so they blame it on the website, but I thought it wasn't possible to set the associated application with the download. I know the file hasn't changed because when I download it and look at it, it indeed is a Registry file.
You can set the content-type, which will hint to the browser how to handle the attached file. This is probably the change causing her problem, I wouldn't be surprised if Drupal is sending your file with some kind of media mime type, when it should probably be text/plain.
I haven't used it but the File MIME module may help you resolve this. I would install this and force .reg files to be sent as text/plain.

Virtual file system in php?

We have a system where, a large part of it is the ability to upload and download files if you are logged in and have the correct permissions.
What we are looking at doing to help with the organization from the users point of view is having a virtual file system type layout.
Even if (or even preferably) all the users files are actually just stored in one directory, and the virtual file system is just a screen put up from the database.
What we are wondering before we invest in creating this is if this already exists somewhere, open source (but able to be used in commercial software), free, or paid (first two preferably!).
A simple file system on top of PHP can be done by WebDAV that is built on top of PHP:
http://sabre.io/
This would be a good example, but there are others as well. WebDAV is essentially a web based file system (http://en.wikipedia.org/wiki/WebDAV).
This could not only provide a file system, but also would let you edit files directly with Word/Excel (2007+) in it. Showing then a treeview of folders and files would be quite trivial, using few database tables and some jquery components, such as jsTree and jqGrid.
Although if you are searching for a full document management system: http://www.opendocman.com/ or http://code.google.com/p/simpledoc/ this would be more then enough.
It really depends on how many features you are going to incorporate into this system. Will there be an OCR, would you like to store the files in the cloud service, how many user input there will be (is simple upload enough, or camera, scanners and other devices are needed to be used as well)?
As for the commercial products, you could check out Microsoft SharePoint (http://en.wikipedia.org/wiki/Microsoft_SharePoint) or IBM Lotus Notes (http://en.wikipedia.org/wiki/IBM_Lotus_Notes)

Large files upload in web browser

This is the first time for me asking a question. Hope you'll be able to help me.
Problem: my chef wants our enterprise application to have a module which allows customers to upload very large files to our server.
Infrastructure: php 5.x / mysql client-server app
Well known problems:
-HTTP session time out
-Upload limit in terms of number of files and file size
Rules:
-The solution mustn't use any applet (java, flash, ...), neither any browser plugin.
-The solution should allow users to upload any type of files, from simple images to very large files of any other type.
-For security reasons, we don't want to change the settings in the php.ini file, neither in any .htaccess file to allow the app uploading larger files.
-If a pre-backed solution exists, it should be opensource and possibly free of charges.
-Integration with AJAX functionalities and progress bar visualisation are heavily welcome.
Possible solutions (tell me if it's possible, and if it isn't, why?):
-Access by FTP using some javascript library in the browser
-Access by WebDAV using some javascript library in the browser
Any other solutions that respect the above given rules is also welcome
I know, I'm asking for a very hard thing to find.
What you're asking for isn't currently possible. The only technology for uploading files which is currently available in all widely used browsers is standard HTTP form uploads, which you've already rejected as a solution. All other solutions available require Java or Flash, or use browser JavaScript capabilities (local file access) which are not fully standardized, nor universally available.
You'll need to relax some of your requirements.
Create an iframe or frame, or browser-window that offers access to the server via FTP. Allows users to drop files there for those browsers at least who support FTP.

Writing files in a Google Chrome extension

I am currently developing my own Google Chrome extension right now. My extension has the functionality to save and retrieve user data(bookmarks, browser preferences) from a local storage in a computer. Right now there are tools and technologies I am considering to use for the development of the said extension. Which brings us to my question:
I know for sure that PHP can be responsible for the file handling which includes storing and retrieving of browser data. My concern is that the security of the written file. Is it possible to put the written text file in a folder which is locked? Is it possible to make that folder account-controlled meaning for the folder to be accessed there should be username and password to be entered? What tool or technology can handle this?

Generate Windows .lnk file with PHP

I'm working on a project which involves an FTP server running ProFTPd and a PHP/MySQL backend that creates accounts for users.
Upon the creation of accounts, users are sent e-mails with their account details and instructions for downloading FileZilla or CyberDuck, depending on their OS, detected via user-agent string.
To make things easier for novices, I thought of having .lnk files generated for FileZilla with the account logins details as parameters, so they would just have to click on the .lnk files to open up the server. This is not a crucial feature but more of a technical challenge.
My questions are :
is this even feasible ?
are there any alternatives (eg. generating a .bat with a script pointing to the Filezilla executable ?)
are there any issues, perhaps with relative / absolute paths pointing to the executable ?
to go even further, what would be the simplest way of providing users with software with FTP access on a single account / single server (web interface is not an option).
It's very difficult to create .lnk files programmatically. See this answer.
In FileZilla, I think the best you can do reliably is to pass along a filezilla.xml file, and describe the steps necessary to import it after FileZilla has been installed.
I don't see any way that you can do this while making it easier for novice users. If you create a shortcut file, you'd have to know the path of the install. Good luck getting that from a user who you assume would have a hard time using a username/password in an FTP program. Even if you got that, you'd be generating the shortcut file after you receive input from the user, then you'd have to email the file to the user or have them download it -> delay.
I would advise against this. Having worked with clueless users before, any attempt to make things "easier" for them but requiring them to do something else usually backfires immensely. Save yourself the headache, and provide a very well-written how-to instead.

Categories