# Configuring File Upload

[https://www.bookstackapp.com/docs/admin/upload-config/#migrating-to-secure-images](https://www.bookstackapp.com/docs/admin/upload-config/#migrating-to-secure-images)

<table border="1" id="bkmrk-migrating-to-%E2%80%9Csecure" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr><td>### Migrating to “Secure” Images

***Back-up your BookStack instance before attempting any migration***

If you are migrating to the `STORAGE_TYPE=local_secure` or `STORAGE_TYPE=local_secure_restricted` options, with existing images, you will need to move all content from your previous image storage location (see above) to the `storage/uploads/images` folder within your BookStack instance.

**Do not simply copy and leave content** in the `public/uploads/images` as those images will still be publicly accessible. After doing this migration you may have to clean-up and re-upload any ‘App Icon’ images, found in settings, since these need to remain publicly accessible.

</td></tr></tbody></table>

<table border="1" id="bkmrk-changing-upload-limi" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr><td>### Changing Upload Limits

By default, a lot of server software has strict limits on upload sizes which causes errors when users upload new content. BookStack enforces its own limit but there may also be limits configured as part of PHP and your web sever software. If you run into problems with upload size limits follow the below details for BookStack, PHP and whichever web server you use.

#### BookStack

The upload limit in BookStack is configured through an option in your `.env` file. Find or add the follow option then configure to your requirements.

<div class="highlight"><div class="chroma"><table class="lntable"><tbody><tr><td class="lntd">```
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-7-1">1</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-7-2">2</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-7-3">3</a>

```

</td><td class="lntd">```bash
# File Upload Limit
# Maximum file size, in megabytes, that can be uploaded to the system.
FILE_UPLOAD_SIZE_LIMIT=50

```

</td></tr></tbody></table>

</div></div>#### PHP

PHP has two main variables which effect upload limits. Find your `php.ini` file and look for the following variables:

- `post_max_size`
- `upload_max_filesize`

If the values of these variables are low increase them to something sensible that’s not too high to cause issues. Unless you need something higher 10MB is a sensible value to enter for these values:

<div class="highlight"><div class="chroma"><table class="lntable"><tbody><tr><td class="lntd">```
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-8-1">1</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-8-2">2</a>

```

</td><td class="lntd">```ini
post_max_size = 10M
upload_max_filesize = 10M

```

</td></tr></tbody></table>

</div></div>If wanting to upload files over 128MB, you may also need to adjust your PHP memory limit like so:

<div class="highlight"><div class="chroma"><table class="lntable"><tbody><tr><td class="lntd">```
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-9-1">1</a>

```

</td><td class="lntd">```ini
memory_limit = 256M

```

</td></tr></tbody></table>

</div></div>After updating these values ensure you restart your webserver and also PHP if using PHP-FPM or something similar.

#### NGINX

By default NGINX has a limit of 1MB on file uploads. To change this you will need to set the `client_max_body_size` variable. You can do this either in the http block in your `nginx.conf` file or in the server block set up for BookStack. Here’s an example of increasing the limit to 100MB in the http block:

<div class="highlight"><div class="chroma"><table class="lntable"><tbody><tr><td class="lntd">```
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-10-1">1</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-10-2">2</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-10-3">3</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-10-4">4</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-10-5">5</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-10-6">6</a>

```

</td><td class="lntd">```nginx
http {
	#...
        client_max_body_size 100m;
        client_body_timeout 120s; # Default is 60, May need to be increased for very large uploads
	#...
}

```

</td></tr></tbody></table>

</div></div>As per the example above, If you are expecting upload very large files where upload times will exceed 60 seconds you will also need to add the `client_body_timeout` variable with a large value.

After updating you NGINX configuration don’t forget to restart NGINX. You can test the configuration beforehand with `nginx -t`.

#### Apache

Apache does not have any built-in limits which you will need to change but something to note is that if you are using apache and mod\_php with `.htaccess` files enabled you may be able to set the above PHP variables in your `.htaccess` file like so:

<div class="highlight"><div class="chroma"><table class="lntable"><tbody><tr><td class="lntd">```
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-11-1">1</a>
<a href="https://www.bookstackapp.com/docs/admin/upload-config/#hl-11-2">2</a>

```

</td><td class="lntd">```apache
php_value upload_max_filesize 10M
php_value post_max_size 10M

```

</td></tr></tbody></table>

</div></div></td></tr></tbody></table>