Unable to upload image

Silverstripe Version:6.2

Question:

When I try to upload an image, no matter if it is in a separate folder or main one, I get the following error:

Something went wrong, please try again


Pretty much impossible to know from that alone, but have a look in the following places:

Server error logs

The network tab in your browser tools. It will show the error code (and if your site is in dev mode, may well show a full error message if you look at the response from the server)

It could be all kinds of things, but often the underlying cause is something like file permissions, memory exhaustion, missing libraries in PHP or just a good old syntax error in the application code somewhere.

Thank you for the quick reply. Currently, it is in production. As I am kinda new to SS, could you please advise which logs would be helpful? Thank you!

If you’re not sure where your server logs are, try adding this to your .env file and testing again to see whether you are getting an error, this should create an error.log file file in your project root.
SS_ERROR_LOG="./silverstripe.log"

If it is a particularly large file (the DSC prefix on the filename suggests it could be a photo from a digital camera) then you may be hitting a memory limit - Often this occurs when Silverstripe is trying to generate a thumbnail, and you may need to increase your php memory limit (or restrict file upload size). Do you get this error on all uploads? Try testing a small .png upload.

Thank you for the suggestion. Please find below the output from the .log file:

[2026-05-09T07:33:16.390002+00:00] error-log.WARNING: E_WARNING: mkdir(): Operation not permitted {“code”:2,“message”:“mkdir(): Operation not permitted”,“file”:“/var/www/site/vendor/silverstripe/assets/src/Filesystem.php”,“line”:48}
[2026-05-09T07:33:16.390825+00:00] error-log.ERROR: Uncaught Exception League\Flysystem\UnableToCreateDirectory: “Unable to create a directory at . mkdir(): Invalid path” at /var/www/site/vendor/league/flysystem/src/UnableToCreateDirectory.php line 18 {“exception”:“[object] (League\Flysystem\UnableToCreateDirectory(code: 0): Unable to create a directory at . mkdir(): Invalid path at /var/www/site/vendor/league/flysystem/src/UnableToCreateDirectory.php:18)”}
[2026-05-09T07:33:16.390863+00:00] error-log.WARNING: E_WARNING: http_response_code(): Calling http_response_code() after header(‘HTTP/…’) has no effect {“code”:2,“message”:“http_response_code(): Calling http_response_code() after header(‘HTTP/…’) has no effect”,“file”:“/var/www/site/vendor/monolog/monolog/src/Monolog/ErrorHandler.php”,“line”:198}
[2026-05-09T07:33:16.687439+00:00] error-log.WARNING: Allowed hosts has not been set. Your application could be vulnerable to host header injection attacks. Either set the SS_ALLOWED_HOSTS environment variable or the AllowedHosts property on SilverStripe\Control\Middleware\AllowedHostsMiddleware

I can see that the main error is “unable to create a directory”, but checking the permissions in the sub folders seems to be just fine:

drwxr-xr-x 7 www-data www-data 4096 May 9 07:31 .
drwxr-xr-x 4 www-data www-data 4096 May 8 06:47 ..
-rw-r–r-- 1 www-data www-data 539 May 3 20:35 .editorconfig
-rw-r–r-- 1 www-data www-data 551 May 9 07:30 .env
-rw-r–r-- 1 www-data www-data 433 May 3 20:35 .env.example
-rw-r–r-- 1 www-data www-data 131 May 3 20:35 .gitignore
drwxr-xr-x 2 www-data www-data 4096 May 3 20:35 .graphql-generated
-rw-r–r-- 1 www-data www-data 46 May 3 20:35 .htaccess
-rw-r–r-- 1 www-data www-data 2108 May 3 20:35 README.md
drwxr-xr-x 4 www-data www-data 4096 May 3 20:35 app
-rw-r–r-- 1 www-data www-data 1294 May 3 20:35 composer.json
-rw-r–r-- 1 www-data www-data 289048 May 3 20:35 composer.lock
-rw-r–r-- 1 www-data www-data 876 May 3 20:35 phpcs.xml.dist
drwxr-xr-x 5 www-data www-data 4096 May 3 21:02 public
-rw-r–r-- 1 www-data www-data 6219 May 9 07:38 silverstripe.log
drwxr-xr-x 3 www-data www-data 4096 May 3 20:35 themes
drwxr-xr-x 31 www-data www-data 4096 May 3 20:35 vendor
-rw-r–r-- 1 www-data www-data 1002 May 3 20:35 web.config