"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"
tpl'; elseif ($admin_page == 'Attributes') $this->mContentsCell = 'admin_attributes.tpl'; elseif ($admin_page == 'AttributeValues') $this->mContentsCell = 'admin_attribute_values.tpl'; elseif ($admin_page == 'Products') $this->mContentsCell = 'admin_products.tpl'; elseif ($admin_page == 'ProductDetails') $this->mContentsCell = 'admin_product_details.tpl'; How It Works: Creating admin_product Even though you can??™t execute the page yet, it??™s worth taking a look at the new elements the new template contains. The admin_product_details.tpl template contains a single form with the enctype="multipart/ form-data" attribute. This attribute is needed for uploading product pictures and works in conjunction with the HTML code that enables file uploading: ...
... The reaction to clicking one of the three upload buttons corresponding to the product images is implemented in the init() method from the AdminProductDetails class (in presentation/admin_product_details.php): // If uploading a product picture ... if (isset ($_POST['Upload'])) { /* Check whether we have write permission on the product_images folder */ if (!is_writeable(SITE_ROOT . '/product_images/')) { echo "Can't write to the product_images folder"; exit(); } // If the error code is 0, the file was uploaded ok if ($_FILES['ImageUpload']['error'] == 0) { CHAPTER 11 ?– CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 339 /* Use the move_uploaded_file PHP function to move the file from its temporary location to the product_images folder */ move_uploaded_file($_FILES['ImageUpload']['tmp_name'], SITE_ROOT .