上传图像SilverStripe时,PHP错误'Filesize为零字节'

I have just set up a new Centos 7 server and uploaded my SilverStripe project via a Capistrano deployment. All is working well except for the file upload where I get a 'Filesize zero bytes' when uploading images.

The assets folder is symlinked to a shared folder outside of the website root.

website
- current
- - (website root)
- shared
- - assets
- - - (uploads)
- - vendor
- - - (composer managed deps)

The file I am uploading is 16kb.

Permissions on all files and directories are set to deployer:apache 755 and permissions on the assets folder has been set to 775 (set it to 777 still with no luck).

There was another post I read that mention php config could be an issue. Here are some of the relevant php settings:

  • max_execution_time: 30
  • max_file_uploads: 20
  • max_input_time: 60
  • post_max_size: 8M
  • upload_max_filesize: 2M
  • upload_tmp_dir: /tmp

Not sure if there are any others that may be on interest, let me know and I will post them.

This is usually due to permissions on the assets directory.

Change the owner of both the symlink and the folder it is linked to

sudo chown -R deployer:apache assets
sudo chown -R deployer:apache /path/to/assets

You might also need to do sudo chmod g+w assets and sudo chmod g+w /path/to/assets to allow other group members to write to your directory.