Exemplo n.º 1
0
  * For uploading images
  */
 if (isset($_POST['image_type'])) {
     switch ($_POST['image_type']) {
         case 'profile':
             if (is_uploaded_file($_FILES['profile-image']['tmp_name'])) {
                 $thumbnail = file_get_contents($_FILES["profile-image"]["tmp_name"]);
             }
             if ($restaurantDb->updateRestaurantThumbnail($resId, $thumbnail)) {
                 $restaurantInfo = $restaurantDb->findRestaurantById($resId);
             }
             break;
         case 'multimedia':
             if (is_uploaded_file($_FILES['multimedia-image']['tmp_name'])) {
                 $img = file_get_contents($_FILES["multimedia-image"]["tmp_name"]);
                 if ($restaurantDb->updateMultimedia($_POST['multimedia-id'], $img, $resId)) {
                     $restaurantImages = $restaurantDb->getRestaurantImages($resId);
                     $imageCount = count($restaurantImages) >= 4 ? 4 : count($restaurantImages);
                 }
             }
             break;
         case 'menu':
             if (is_uploaded_file($_FILES['menu-image']['tmp_name'])) {
                 $menu = file_get_contents($_FILES["menu-image"]["tmp_name"]);
             }
             if ($restaurantDb->updateRestaurantMenu($resId, $menu)) {
                 $restaurantInfo = $restaurantDb->findRestaurantById($resId);
             }
             break;
     }
 }