ExpressionEngine: thumbnail could not be created for the image under Windows
I'm a Windows user and I'm working on a ExpressionEngine based site. I'm using EasyPHP as a server and everything works as expected. However, once I decided to upload a file I got "Thumbnail could not be created for the image. Please make sure the thumbnail directory is writable.".
The problem was in the format of the path. Windows require \\ (back slash) and not / (forward slash. In my case the configuration is used in a PHP file. I'm using the setup suggested by Focus Lab. You may read more about it here. All I need to do is to write a script that makes the change. And of course only when the current environment is Windows. So, here it is:
// converting / to \\ because of Windows if(defined('PHP_OS') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $env_config['upload_preferences'][1]['server_path'] = str_replace("/", "\\\\", $env_config['upload_preferences'][1]['server_path']); }
If you don't use any fancy setup for the configurations, then simply go to CP Home > File Manager > File Upload Preferences > Edit File Upload Preferences and update the value of Server Path to Upload Directory.