I’m implementing a file upload, Directory and Imageupload class in php. What I have planned to implement in Directory class, are the following functions such as:
- Retrieve list of files, folder in a directory
- Create folder, search recursively in a directory
{path}
In FileHandling.class.php following methods such as:
- whether file exists in a directory, . c
- check file extension of file uploading
- Handling moving files from a location to another
- Renaming a file
In imageUpload.class.php functions such as:
- resizing image,
- creating watermark.
What I would like to know , where should the function exist, should I have only one fileHandling.class.php and it includes method of Directory.class.php, or keep them separate.
Should ImageUpload.class.php be composition of fileUpload.class.php? And what particular software pattern can I apply here such as Facade, Singleton etc.
You should confine all FileSystem operations to one Factory. Use the Factory pattern to compartmentalize Uploads, File Listing etc