This is Windows so setting permissions is a little bit different than in Linux, I know that it requires write and execute permissions, full permissions are granted (equivalent to 777 in Linux) but still doesn't work. Will try in WSL but it should work in Windows too, I have no problems with write permission when I use my own PHP scripts.
Edit: Ok, looks it was Apache's configuration causing this problem (virtual host settings for this directory), changed and now it works.