> For the complete documentation index, see [llms.txt](https://simcycreative.gitbook.io/signer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simcycreative.gitbook.io/signer/php-functions/files-manager/upload.md).

# Upload

This is one function that uploads and validates files, crop/resize images among other features.

## Parameters

| Parameter | Required | Type         | Description                                                                      |
| --------- | -------- | ------------ | -------------------------------------------------------------------------------- |
| $file     | Yes      | **`string`** | This could be a url path to a file, base64 image or $\_FILES from a form.        |
| $storage  | No       | **`string`** | The folder inside **`/uploads`** to save the uploaded file. default is *general* |
| $options  | No       | **`array`**  | Explained on the table below.                                                    |

### $options explanation

| Key               | Type         | Description                                                                                         |
| ----------------- | ------------ | --------------------------------------------------------------------------------------------------- |
| source            | **`string`** | Define the source of your file *( form* \| *base64* \| *url )* Default if *form*.                   |
| extension         | **`string`** | The extension(png, pdf, .....) of your output, this is required if your *source* is *url*.          |
| allowedExtensions | **`string`** | Allowed extension separated by a comma, the upload will fail if extension don't match.              |
| resize            | **`array`**  | Pass this array if you are uploading an image you want to crop. Sample array on usage section below |
| crop              | **`array`**  | Pass this array you are uploading an image to resize. Sample array of the usage section below       |

## Usage

```php
use Simcify\File;

File::upload(
    "https://example.com/image.png", 
    "books",
    array(
        "source" => "url",
        "extension" => "png"
        "allowedExtesions" => "png, jpg, gif",
        "crop" => array(
                    "width" => "300",
                    "height" => "300"
                  ),
        "resize" => array(
                    "maxWidth" => "300",
                    "maxHeight" => "300"
                  )
    )
)
```

## Response

```php
array(
    "status" => "success",
    "title" => "File Uploaded",
    "message" => "File successfully uploaded.",
    "info" => array(
        "name" => $fileName,
        "path" => $outputFile,
        "extension" => $options['extension'],
        "size" => $fileSize,
        )
)
```
