How can I upload files using php

How can I upload files using php

I want to create a file sharing service and I want to upload those files to R2. I want some code, examples of how to upload those files to storage and how to delete them.

Thank YOU

R2 is S3 Compatible, so any S3 Library for PHP that supports setting custom endpoints like even aws’s aws-sdk-php can be used with R2, and thus any examples with them as well.

Example of using aws-sdk-php with R2 here: aws-sdk-php · Cloudflare R2 docs

Then you can look for examples on doing that with aws-sdk-php.

1 Like