Prev | Current Page 442 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"


CHAPTER 11 ?–  CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 340
?– Note A complete description of the $_FILES superglobal is available at http://www.php.net/manual/
en/features.file-upload.php.
The move_uploaded_file() PHP function is used to move the file from the temporary location to the
product_images folder:
/* 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 . '/product_images/' .
$_FILES['ImageUpload']['name']);
After uploading a product picture, the file name must be stored in the database (otherwise, the file upload has no
effect):
// Update the product's information in the database
Catalog::SetImage($this->_mProductId,
$_FILES['ImageUpload']['name']);
As you can see, it??™s pretty simple to handle file uploads with PHP.
Product Details: Implementing the Business Tier
To implement the business tier, you??™ll need to add the following methods to the Catalog class:
??? UpdateProduct updates a product??™s details: name, description, price, and discounted
price.
??? DeleteProduct completely removes a product from the catalog.
??? RemoveProductFromCategory is called when the ???Remove from category??? button is
clicked to unassign the product from a category.
??? GetCategories returns all the categories from our catalog.


Pages:
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
stretching exercises grow taller pozycjonowanie strony texas holdem zasady imprezy integracyjne dla firm poker online