8.3. Writing the Image Handling Class

Your first step, of course, is to define the ImageHandler class. You want this class to be portable, so you should create a separate file for it called images.inc.php. You save this file in the inc folder (full path: /xampp/htdocs/simple_blog/inc/images.inc.php). After you create images.inc.php, insert the following code to define the class:

<?php

class ImageHandler
{

}

?>

8.3.1. Saving the Image

So far you've defined your class is defined; next, you need to determine what methods and properties you need to define.

You need a public method that saves the uploaded image in a folder and returns its path. You also need a public property that stores the folder you want your images saved in. This property is ...

Get PHP for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.