I tried everything suggested in this tread e.g. setting all permissions 777, setting user:group apache, setting uploadtempdir, etc.
What worked for me was turning off SELinux e.g. setenforce 0
The following note on the following link specifies how to create the correct SELinux security policy which will allow you to upload files using moodle . . .
Note: If you are installing Moodle on a server that supports SELinux (e.g. RedHat or Fedora desktop) then you will need to ensure that your data directory's security context is set correctly. httpd_sys_content_rw_t is required for all content which needs to available to httpd scripts. Use the chcon command to set the context, for example chcon -R -t httpd_sys_content_rw_t var/www/moodledata