Skip to content
Fragmented Development

Manipulating Files Without the Filesystem Functions

GoDaddy doesn't allow sites to write files to the filesystem using the PHP filesystem functions. This may be due to security concerns, but it put a kink in the comic system. Storing strip images could always be done through the database, but that adds a whole extra layer of complexity and performance drain to the application.

To get around these drawbacks, I ended up using the FTP extension to bypass the Filesystem extensions entirely. GoDaddy allows you to upload your files through FTP, so I created a second account for the site itself to use and funneled all of the files through the FTP functions. I abstracted as much of this as possible, so that if we ever regain the use of the filesystem functions I can switch to those without much hassle.

This method worked incredibly well, considering it was originally meant as a workaround. FTP provides almost all of the basic functionality of the filesystem functions, but it does require the extra overhead of managing a connection and requiring a username and password. I would be interested in seeing if there was any performance cost involved with running through the extra layer of abstraction.

One glaring issue came up while using the FTP functions in place of the filesystem functions: temporary files. The FTP functions (at least in PHP 4) did not really provide a mechanism for creating and working with temporary files. Uploading a file through a form worked flawlessly, and I could manage files that already existed in the filesystem, but creating a new file and then saving it somewhere wasn't really possible. This really interfered with some cool CSS tricks I had planned, and I honestly haven't really figured out a workaround for it just yet.

Again, as someone who manages a server, I can very well see this being a security issue. While I empathize, I also wish there was some way to provide this functionality. If PHP 5 was available, I believe I could have gotten by with some of the newer FTP functionality.

Anyways, if I can get it together to gather the FTP workarounds I came up with into a file that can be included, I may post it here later. Maybe it will be useful to someone?

Tags: php


Add Your Comment