I'm trying to move images from one folder to another. I'm using the following code:
rename("/public_html/wp-content/uploads/image.png","/public_html/wp-content/uploads/folder/image.png");
The image gets moved fine to the new folder and the new path is accessible, only the image breaks. It gets a file size of 0.01k and shows the broken image icon.
I'm using the same rename function for files and folders and everything gets moved without any problems. What could be the problem for the images?
EDIT: The problem only seems to occur when the code gets fired from an ajax request. If I load the same code directly it works fine. If it gets loaded from ajax the image breaks.