Now we are using those two libraries to add some cool functionalities to our website monitoring tool. Among all the data we have collected for our sites, it would be very helpful to have an image of the site itself. This will allow us to have a list of sites with a thumbnail helping us recognize the site very easily.
Our first step will be to create a folder, where we can keep the uploaded files. These may be text, images, or more exotic file types such as MP3 audio or MPEG video. Uploading is a more complex process than the file downloads we just discussed, but CI's upload
class takes care of most of the work for you. It also looks after some of the security issues. The folder must be set with the correct permissions, allowing users to write to it (that is, 777 on a Unix/Linux system). Let's assume you call this folder uploads
, and put it in your website's root folder.
If we want to upload files we will need an upload form. Let's build a controller...