Photos:
You can store the photos in your Photos app on iCloud by turning on iCloud Photos. See instructions in Set up and use iCloud Photos - Apple Support
Your photos will then be both in iCloud and on your Mac (an also synced with any other Apple devices where you have iCloud Photos turned on. If you want to reduce the amount of storage space that they use on your Mac, turn on the Optimize Storage option for Photos. See the following excerpts from that same Apple Support article:
iCloud Photos keeps all your photos and videos in their original, high-resolution version. To save storage space on your device, you can turn on Optimize Storage.
If you turn on Optimize Storage, iCloud Photos automatically manages the size of your library on your device. Your original photos and videos are stored in iCloud and space-saving versions are kept on your device. Your library is optimized only when you need space, starting with the photos and videos you access least. You can download the original photos and videos over Wi-Fi or cellular when you need them.
On your Mac
- Open the Photos app and click Photos in the menu bar.
- Click Settings or click Preferences.
- Go to the iCloud tab and choose a storage setting.
Other Files:
To sync other files with iCloud, turn on iCloud Drive. See instructions in Set up iCloud Drive - Apple Support
When iCloud Drive is turned on in your Mac, any files that you move to the iCloud Drive folder in Finder will sync with iCloud. You can access the iCloud Drive folder from the Finder sidebar and from the Finder "Go" menu at the top of the screen.
There is also an option to automatically sync all of the files and folders on your Desktop and in your Documents folder by turning on the Desktop and Documents option of iCloud Drive. See instructions in Add your Desktop and Documents files to iCloud Drive - Apple Support
Note that there is no option to sync files in folders that are not in the iCloud Drive folder or the Desktop and Documents folders.