Remove directory and all its content in PHP

To recursively delete all the contents in the directory and then the directory itself. This function checks for files and sub directories and delete them first before deleting the main folder.

$directory      = "uploads";
 
if(is_dir($directory)){
	recursiveRemoveDirectory($directory);
}
 
function recursiveRemoveDirectory($directory) {
    foreach(glob("{$directory}/*") as $file) {
        if(is_dir($file)) {
            recursiveRemoveDirectory($file);
        } else {
            unlink($file);
        }
    }
    rmdir($directory);
}

Increase Image Upload File Size Limit on OpenCart

OpenCart’s default image upload size is 300KB and that is simply too small for clients that don’t have the knowledge to resize their images before uploading them. Although uploading digital camera images does use more bandwidth, sometimes it can not be avoided. To adjust the image upload size make the following changes around line 436 of admin/controller/common/filemanager.php:

if ($this->request->files['image']['size'] > 3000000) {
	$json['error'] = $this->language->get('error_file_size');
}

In this case we have increased the upload size limit to 10MB, also make sure that your php configuration will allow file uploads and posts of this size.