All posts
Published in PHP

Upload File to Digital Ocean Space with PHP

Profile image of Atakan Demircioğlu
By Atakan Demircioğlu
Fullstack Developer

Here are my notes on uploading a file to Digital Ocean space with PHP.

Upload File to Digital Ocean Space with PHP image 1

Why use Digital Ocean Space?

If you are familiar with AWS S3, we can say it is a mirror thing in another Cloud provider. You can upload files, images, etc to a Digital Ocean space.

  • 1 TB of data for $5/month. (Cheaper than AWS S3)
  • No request fees
  • Easy to use

So there are many ways to use Digital Ocean Space, I just wrote a basic part uploading in base 64 format.

In my first letters, I said it is a mirror of S3. So we can use AWS SDK for uploading files to Digital Ocean Space.

Firstly install via composer;

composer require aws/aws-sdk-php

PHP Side

This is an example of uploading base 64 encodings, so on the client side, I am sending a string of image in base 64 formats to the backend.

A minor example for React side about how to convert to base64 string