"Access denied" error on 'rename' call when uploading files in Symfony "Access denied" error on 'rename' call when uploading files in Symfony symfony symfony

"Access denied" error on 'rename' call when uploading files in Symfony


I've been running into the same exact issue recently. I don't really have a good sense of why the problem is happening, but the problem is coming from a step in the process where Doctrine is trying to generate proxy classes.

In my config.yml file, under the ORM section of the Doctrine configuration, I changed the value of auto_generate_proxy_classes from %kernel.debug% to false. I've played with it for a while since making the change and haven't been able to reproduce the issue since.


Found this while looking for same answer, it seems to be a windows + Doctrine issue.

Doctrine Ticket with more detailed info

TLDR: Basically the proxy is trying to rename a file that's still being used, works in Linux but not always on windows.


Go to the file that renames the file, then replace it with a windows compatible rename function

private function renameWindowsCompatible($oldfile,$newfile) {    try {        rename($oldfile,$newfile);    } catch(\Exception $e) {        if (copy($oldfile,$newfile)) {            unlink($oldfile);            return TRUE;        }        return FALSE;    }    return TRUE;}