> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload images in PHP (video tutorial)

[githublink]: https://github.com/cloudinary-devs/php_upload

## Overview

Learn how to upload images in PHP using the Cloudinary PHP SDK.

## Video tutorial

  This video is brought to you by Cloudinary's video player - embed your own!Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.

> **TIP**: :title=View the code

You can find the code from this tutorial in [GitHub][githublink].
## Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.### Introduction
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=00 :player=cld} | In this tutorial, you'll learn how to upload one or more images to Cloudinary using the PHP SDK, a crucial part of your workflow for managing visual media.

### Upload a single image from your local file system
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=15 :player=cld} | This tutorial assumes you've already [installed and configured the PHP SDK](php_configuration_tutorial). To begin uploading, import the necessary Cloudinary classes, create an instance of the `UploadApi` class, and call the upload method with the full path to your image. Here's a basic example using a file in your `images/` folder:

```php
use Dotenv\Dotenv;
use Cloudinary\Cloudinary;
use Cloudinary\Configuration\Configuration;
use Cloudinary\Api\Upload\UploadApi;

// Load .env file
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();

// Initialize Configuration
$config = new Configuration($_ENV['CLOUDINARY_URL']);

$cld = new Cloudinary($config);

$upload = new UploadApi($config);

// Upload the first image
$response = $upload->upload('images/people-walking.jpg');
```

### Upload response
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=51 :player=cld} | Once executed, the script will return a response object containing metadata and the delivery URL. You can use the `secure_url` to access the uploaded image:

```php
echo $response['secure_url'];
```

### Upload multiple images from your local file system
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=1 :sec=12 :player=cld} | To upload multiple images, loop through an array of file paths and upload each one individually. Only the `secure_url` is printed for simplicity. You can also view all uploaded images in the [Media Library](media_library_for_developers#viewing_assets).

```php
// Array of image paths
$imagePaths = [
   'images/dress.jpg',
   'images/drinks.jpg',
   'images/fruit.jpg',
   'images/shoes.jpg'
];

foreach ($imagePaths as $imagePath) {
   // Upload the image
   $response = $upload->upload($imagePath);
   // Print the secure URL from the response
   echo "<pre>***** Uploaded $imagePath: " . $response['secure_url'] . "</pre>";
}
```

### Upload a single image from a remote URL
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=1 :sec=52 :player=cld} | You can also upload images hosted online by passing the image's direct URL instead of a local file path. Cloudinary will download and store the file:

```php
$response = $upload->upload("https://raw.githubusercontent.com/cloudinary-devs/cld-docs-assets/refs/heads/main/assets/images/people-walking.jpg");

// Print the secure URL from the response
echo "<pre>***** Uploaded remote image: " . $response['secure_url'] . "</pre>";
```
## Keep learning

> **READING**:
>
> * Learn more about [uploading images and videos using the PHP SDK](php_image_and_video_upload).

> * Take a look at our [Upload guide](upload_images) to learn about uploading to Cloudinary in general.

> * Use the [Upload API reference](image_upload_api_reference) to find all the options and parameters available.

> * Watch more [Dev Hints videos](https://www.youtube.com/playlist?list=PL8dVGjLA2oMpaTbvoKCaRNBMQzBUIv7N8) on the [Cloudinary YouTube channel](https://www.youtube.com/cloudinary).

#### If you like this, you might also like...

  
  
  
    Configure the PHP SDK
    Install and configure the Cloudinary PHP SDK 
  

  
  
  
    Upload Programmatically
    Use a Cloudinary SDK to upload media assets 
  

  
  
  
    Use a Webhook to Remove Backgrounds on Upload
    Use a webhook notification to remove image backgrounds on upload 
  

&nbsp;

&nbsp;Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
&nbsp;