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

# Upload Files

**Loading File Library**

```php
public $file;
function __construct(){
    $this->file = $this->library("file");
}
```

<table><thead><tr><th>Method</th><th width="134">Arguments</th><th>What does this do?</th><th width="100" align="center">Req*?</th></tr></thead><tbody><tr><td>setFileName</td><td>$fileName</td><td>Sets the File Name</td><td align="center">Yes</td></tr><tr><td>setUploadPath</td><td>$path</td><td>Sets the Upload Path</td><td align="center">Yes</td></tr><tr><td>setAllowedFileTypes</td><td>$array</td><td>Sets the alowed file types</td><td align="center">No</td></tr><tr><td>setMaxSize</td><td>int Bytes</td><td>Sets Max File Size</td><td align="center">Yes</td></tr><tr><td>setField</td><td>string Form Field</td><td>Sets Field from POST Value</td><td align="center">Yes</td></tr></tbody></table>

### Upload Files

```php
$file->setFileName("_FILE.jpg");
$file->setUploadPath("upload");
$file->setAllowedFileTypes(["jpg","png","jpeg"]);
$file->setMaxSize(50000);
$file->setField("file");

$file->upload(); //=> ["FILE_NAME" => ""]
```
