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
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
What’s a bit curious is the path that is in the error. It seems to be blank.
Can you just confirm..
Is this a brand new install?
Where are you trying to upload the image file? Is it in a page, in the files section, etc.
Have you run a dev/build recently? If not, try it, it can’t hurt!
Hello,
This is a brand new install. I tried to upload photos in files - both in main folder or custom created one
I just run the dev/build and no errors:
Creating database tables
* File (1 records)
* SiteConfig (1 records)
* ChangeSet (7 records)
* ChangeSetItem (7 records)
* FileLink (0 records)
* SiteTree (18 records)
* SiteTreeLink (0 records)
* Group (2 records)
* LoginAttempt (10 records)
* Member (1 records)
* MemberPassword (2 records)
* Permission (5 records)
* PermissionRole (0 records)
* PermissionRoleCode (0 records)
* RememberLoginHash (0 records)
* LoginSession (3 records)
* BrokenExternalLink (0 records)
* BrokenExternalPageTrack (0 records)
* BrokenExternalPageTrackStatus (0 records)
* Folder
* Image
* Page
* ErrorPage (2 records)
* RedirectorPage (0 records)
* VirtualPage (0 records)
Creating database records
* SilverStripe\Assets\File
* SilverStripe\SiteConfig\SiteConfig
* SilverStripe\Versioned\ChangeSet
* SilverStripe\Versioned\ChangeSetItem
* SilverStripe\Assets\Shortcodes\FileLink
* SilverStripe\CMS\Model\SiteTree
* SilverStripe\CMS\Model\SiteTreeLink
* SilverStripe\Security\Group
* SilverStripe\Security\LoginAttempt
* SilverStripe\Security\Member
* SilverStripe\Security\MemberPassword
* SilverStripe\Security\Permission
* SilverStripe\Security\PermissionRole
* SilverStripe\Security\PermissionRoleCode
* SilverStripe\Security\RememberLoginHash
* SilverStripe\SessionManager\Models\LoginSession
* SilverStripe\Reports\ExternalLinks\Model\BrokenExternalLink
* SilverStripe\Reports\ExternalLinks\Model\BrokenExternalPageTrack
* SilverStripe\Reports\ExternalLinks\Model\BrokenExternalPageTrackStatus
* SilverStripe\Assets\Folder
* SilverStripe\Assets\Image
* Page
* SilverStripe\ErrorPage\ErrorPage
What do the file permissions / ownership look like for the files / directories in public and in public/assets ?
/var/www/site/public$ ls -la
total 36
drwxr-xr-x 5 www-data www-data 4096 May 3 21:02 .
drwxr-xr-x 7 www-data www-data 4096 May 9 07:31 ..
-rw-r–r-- 1 www-data www-data 1399 May 3 20:35 .htaccess
drwxr-xr-x 2 www-data www-data 4096 May 3 20:35 _graphql
drwxr-xr-x 4 www-data www-data 4096 May 3 20:35 _resources
drwxr-xr-x 3 www-data www-data 4096 May 12 14:43 assets
-rw-r–r-- 1 www-data www-data 2587 May 3 20:35 favicon.ico
-rw-r–r-- 1 www-data www-data 715 May 3 20:35 index.php
-rw-r–r-- 1 www-data www-data 1196 May 3 20:35 web.config
/var/www/site/public/assets$ ls -la
total 52
drwxr-xr-x 3 www-data www-data 4096 May 12 14:43 .
drwxr-xr-x 5 www-data www-data 4096 May 3 21:02 ..
-rw-r–r-- 1 www-data www-data 41 May 3 20:35 .gitignore
-rw-r–r-- 1 www-data www-data 1222 May 12 14:43 .htaccess
drwxr-xr-x 2 root root 4096 May 12 14:43 .protected
-rw-rw-r-- 1 www-data www-data 10819 May 12 14:43 error-404.html
-rw-rw-r-- 1 www-data www-data 10715 May 12 14:43 error-500.html
-rw-r–r-- 1 www-data www-data 4408 May 3 20:35 web.config
I just noticed that .protected is root/root. Could it be that this is the issue?
There’s a good chance, yes. The ownership is important and those permissions won’t allow other users to create files. (Plus, having the root user owning files in the web space is problematic)
If you recursively change the ownership of that directory to your web user, hopefully that will cure it.