I’ve come across a curious problem. The short story is that I have a form where a user uploads a photo. I move that photo into a files folder and then copy that photo into an images folder. For some reason I’m not able to copy the image into that specific folder unless I change the name of it.
Here’s the copy code:
[CODE]copy(‘/absolute/path/to/files/file.jpg’,’/absolute/path/to/images/file.jpg’);
I don’t get any errors or anything, but it just doesn’t work. Also, I have permissions set to 777 on everything.
The more curious part is I CAN copy the image several other ways. All the examples below work:
// Copy to parent folder
[CODE]copy(‘/absolute/path/to/files/file.jpg’,’/absolute/path/to/file.jpg’);
// Copy with a different name
[CODE]copy(‘/absolute/path/to/files/file.jpg’,’/absolute/path/to/images/file_2.jpg’);
// Copy to parent folder with a different name, rename to original name
[CODE]copy(‘/absolute/path/to/files/file.jpg’,’/absolute/path/to/images/file_2.jpg’);
rename(‘/absolute/path/to/file_2.jpg’,’/absolute/path/to/file.jpg’);
I even tried copying the image to the correct folder with a different name and then renaming it to the original name like this:
[CODE]copy(‘/absolute/path/to/files/file.jpg’,’/absolute/path/to/images/file_2.jpg’);
rename(‘/absolute/path/to/images/file_2.jpg’,’/absolute/path/to/images/file.jpg’);
But that doesn’t work. I can rename it to something else in the intended folder (say file_2a.jpg) but I can’t rename it to what it originally was.
I’ve tried deleting the folder (/images/) and recreating it. I’ve tried several different files and file types. I’ve tried usting file_get_contents/fopen/fwrite instead of copy, but nothing works.
Any ideas?