public function UploadGalleryImages($id)
 {
     if (isset($_POST["editGalleryInfoButton"])) {
         $title = $_POST["galleryTitle"];
         if (Input::hasFile("galleryPicture")) {
             $hasImage = true;
             $file = Input::file("galleryPicture");
             $folder = '/images/';
             $destinationPath = public_path() . $folder;
             $filename = str_random(6) . '_' . $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $image = $folder . $filename;
         } else {
             $image = "";
             $hasImage = false;
         }
         Gallery::UpdateGalleryInfo($id, $title, $image, $hasImage);
         return Redirect::to("admin/edit_gallery/" . $id);
     }
     if (isset($_POST["uploadImagesButton"])) {
         echo "uploading";
         $tmp_name_array = $_FILES['imagesToUpload']['tmp_name'];
         //get the temporary file names
         for ($i = 0; $i < count($tmp_name_array); $i++) {
             //traverse through them
             $name = "images/" . str_random(6) . '_' . $_FILES['imagesToUpload']['name'][$i];
             //upload file to server
             move_uploaded_file($tmp_name_array[$i], $name);
             Gallery::InsertImageToDB($id, $name);
         }
         return Redirect::back();
     }
     if (isset($_POST["deletePicsButton"])) {
         foreach ($_POST["imagesCheckboxGroup"] as $id) {
             $pd = Gallery::GetSingleImage($id);
             $img = $pd[0]->image_path;
             if (File::exists(public_path() . $img)) {
                 File::delete(public_path() . $img);
             }
             Gallery::DeleteImage($id);
         }
         return Redirect::back();
     }
 }