Imported from the Apple Support Forums via the Wayback Machine 🔗
Hello.
There's no way to use iCloud as a storage and wipe off all of your photos from the phone, unfortunately.
But if you are running out of space on your iPhone, you can turn on 'Optimize iPhone Storage' option under Settings > Photos.
Once you do so, iCloud will automatically remove full-resolution versions of older images from your device, storing only the most recent images locally.
The rest of those images and video will continue to be stored safely in iCloud at full resolution and in their native format.